Jump to content
Sign in to follow this  
Coding_Camel

Array Error when adding items to array

Recommended Posts

Recently i've been working on a vehicle saving script for a life mission... It works with one vehicle, where there is a variable carrying a single item like LAND_CAR. When I try to do this with arrays, it says "Type string, expected array", the error happens when count INV_SavedVehicle happens.

The code is very messy, as i'm not looking for perfection yet, just something that works with an array.

Variable is declared in seperate SQF like this

INV_SavedVehicle = [];

Save code

_ArryLength = count INV_SavedVehicle;


if(_ArryLength >= 3) then {

player groupChat "You can not save more than 3 vehicles, to get more please remove a vehicle at the retrieve vehicle box...";

} else {

_vcl = (nearestobjects [getpos player, ["Air", "Ship", "LandVehicle"], 3] select 0);

_vclClass = typeOf _vcl;

player globalchat format ["VEHICLE ARRAY : %1",_vcl]; // debug


INV_SavedVehicle set [count INV_SavedVehicle, _vclClass];

player globalchat format ["SAVED ARRAY : %1",INV_SavedVehicle]; // debug

deleteVehicle _vcl;

player groupChat "VEHICLE SAVED, YOU MAY RETRIEVE IT AT THE VEHICLE RETRIEVE POINT!";


["INV_SavedVehicle",INV_SavedVehicle] spawn clientsavevar;

};

The save code is executed from an action. Hopefully someone can help.

Thanks,

Camel

Share this post


Link to post
Share on other sites

Not much help here as it seems to work.

I have a radio trigger with the execvm in it and when I get close to a vehicle I use radio trigger .

I can save three vehicles and they vanish no errors.

could the error be in here ["INV_SavedVehicle",INV_SavedVehicle] spawn clientsavevar;

Share this post


Link to post
Share on other sites

["INV_SavedVehicle",INV_SavedVehicle] spawn clientsavevar;

is not the issue, that's just a custom function that writes it to the database.

---------- Post added at 16:15 ---------- Previous post was at 16:08 ----------

I got it to work, appears as though there was another conflicting variable (No idea what though, searched the whole variables file)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×