English Solved Need help troubleshooting a script error

  • Auteur de la discussion Auteur de la discussion LogicLion
  • Date de début Date de début

LogicLion

User
5/1/21
14
5
250
I have a script that allows people going to chop shop, check who the owner of the vehicle is. The vehicle cannot be chopped unless the owner is notified first. Unfortuantly, for some reason it did work, but no longer does. The error I get when i click "Check owner" in the chop shop menu, it has this


Code:
17:58:08   Error position: <:3789>
17:58:08   Error :: Type Number, expected switch

This is the only error message I get, when clicking the "Check Owner" button.

The code for the check owner is

C++:
#include "..\..\script_macros.hpp"
/*
    File: fn_chopCheck.sqf
    Author: System32
    
    Description:
        Check the owner of a vehicle, if owner is notified of the ransom, allow the player to chop it.
        Vehicle cannot be chopped if the owner hasn't been notified.   
*/

disableSerialization;
private["_control","_vehicle"];
_control = CONTROL(39400,39402);
_vehicle = _control lbData (lbCurSel _control);
_vehicle = call compile format["%1", _vehicle];
_nearVehicles = nearestObjects [getMarkerPos (_this select 3),["Car","Truck","Air"],25];
_vehicle = _nearVehicles select _vehicle;
_vehicleData = _vehicle getVariable ["vehicle_info_owners",[]];
if ((count _vehicleData) isEqualTo 0) exitWith {deleteVehicle _vehicle};
private _owner = ((_vehicleData select 0) select 1);
if(isNull _vehicle) exitWith {};
private _stats = _vehicle getVariable ["dbInfo",[]];
if ((count _stats) isEqualTo 0) exitWith {hint "This vehicle is bugged"}; //not valid vehicle

private _vehicleName = getText(configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "displayName");

{if (getPlayerUID _x isEqualTo (_stats select 0)) exitWith {_owner = _x}} forEach playableUnits;

if (isNull _owner) then
    {
        hint "The owner is offline currently, chop away!";
    };
if !(isNull _owner) then
    {
        hint format ["The owner of this vehicle is %1 and they are online, please msg them to let them attempt a ransom!",(name _owner)];
        [0,"Someone is trying to chop your %1 vehicle!",_vehicleName] remoteExecCall ["life_fnc_broadcast",_owner];
    };

_vehicle setVariable["checked",true,true];

I dont see anywhere, where the error could happen from. Just looking for some help
 
Solution
In your file, try to replace :
Code:
_vehicle = _control lbData (lbCurSel _control);
_vehicle = call compile format["%1", _vehicle];
_nearVehicles = nearestObjects [getMarkerPos (_this select 3),["Car","Truck","Air"],25];
_vehicle = _nearVehicles select _vehicle;
by :
Code:
private _vehicle = objectFromNetId (_control lbData (lbCurSel _control));
Thanks for your reply.

The full error is posted above. That's all it gives me which is why its confusing.

The file is default fn_chopShopSell.sqf


C++:
#include "..\..\script_macros.hpp"
/*
    File: fn_chopShopSell.sqf
    Author: Bryan "Tonic" Boardwine

    Description:
    Sells the selected vehicle off.
*/
disableSerialization;

private _control = CONTROL(39400,39402);
private _price = _control lbValue (lbCurSel _control);
private _vehicle = objectFromNetId (_control lbData (lbCurSel _control));
if (isNull _vehicle) exitWith {};
// if!(_vehicle getVariable["checked",false]) exitWith {hint "You need to check and message owner for a chance to ransom the vehicle back"};

systemChat localize "STR_Shop_ChopShopSelling";
life_action_inUse = true;

if (life_HC_isActive) then {
    [player,_vehicle,_price] remoteExecCall ["HC_fnc_chopShopSell",HC_Life];
} else {
    [player,_vehicle,_price] remoteExecCall ["TON_fnc_chopShopSell",RSERV];
};

if (LIFE_SETTINGS(getNumber,"player_advancedLog") isEqualTo 1) then {
    if (LIFE_SETTINGS(getNumber,"battlEye_friendlyLogging") isEqualTo 1) then {
        advanced_log = format [localize "STR_DL_AL_choppedVehicle_BEF",_vehicle,[_price] call life_fnc_numberText,[CASH] call life_fnc_numberText];
    } else {
        advanced_log = format [localize "STR_DL_AL_choppedVehicle",profileName,(getPlayerUID player),_vehicle,[_price] call life_fnc_numberText,[CASH] call life_fnc_numberText];
    };
    publicVariableServer "advanced_log";
};

closeDialog 0;


The button in the chop shop menu:

Code:
class Chop_Shop {
    idd = 39400;
    movingEnable = 0;
    enableSimulation = 1;

    class controlsBackground {
        class RscTitleBackground: Life_RscText {
            colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", "(profilenamespace getvariable ['GUI_BCG_RGB_A',0.7])"};
            idc = -1;
            x = 0.1;
            y = 0.2;
            w = 0.32;
            h = (1 / 25);
        };

        class MainBackGround: Life_RscText {
            colorBackground[] = {0,0,0,0.7};
            idc = -1;
            x = 0.1;
            y = 0.2 + (11 / 250);
            w = 0.32;
            h = 0.6 - (22 / 250);
        };

        class Title: Life_RscTitle {
            colorBackground[] = {0,0,0,0};
            idc = -1;
            text = "$STR_ChopShop_Title";
            x = 0.1;
            y = 0.2;
            w = 0.32;
            h = (1 / 25);
        };

        class priceInfo: Life_RscStructuredText {
            idc = 39401;
            text = "";
            sizeEx = 0.035;
            x = 0.11;
            y = 0.68;
            w = 0.2;
            h = 0.2;
        };
    };

    class controls {
        class vehicleList: Life_RscListBox {
            idc = 39402;
            onLBSelChanged = "_this call life_fnc_chopShopSelection";
            sizeEx = 0.04;
            x = 0.11;
            y = 0.25;
            w = 0.3;
            h = 0.38;
        };

        class BtnSell: Life_RscButtonMenu {
            idc = -1;
            text = "$STR_Global_Sell";
            onButtonclick = "[] call life_fnc_chopShopSell;";
            x = 0.1 + (6.25 / 40) + (1 / 250 / (safezoneW / safezoneH));
            y = 0.8 - (1 / 25);
            w = (6.25 / 40);
            h = (1 / 25);
        };

        class BtnClose: Life_RscButtonMenu {
            idc = -1;
            text = "$STR_Global_Close";
            onButtonClick = "closeDialog 0";
            x = 0.1;
            y = 0.8 - (1 / 25);
            w = (6.25 / 40);
            h = (1 / 25);
        };
        
        class BtnCheck : Life_RscButtonMenu
        {
            idc = -1;
            text = "$STR_Global_Check";
            onButtonClick = "[] call life_fnc_chopShopCheck;";
            x = 0.1;
            y = 0.805;
            //w = (6.25 / 40);
            w = 0.32;
            h = (1 / 25);
        };
    };
};
 
In your file, try to replace :
Code:
_vehicle = _control lbData (lbCurSel _control);
_vehicle = call compile format["%1", _vehicle];
_nearVehicles = nearestObjects [getMarkerPos (_this select 3),["Car","Truck","Air"],25];
_vehicle = _nearVehicles select _vehicle;
by :
Code:
private _vehicle = objectFromNetId (_control lbData (lbCurSel _control));
 
Solution