Jump to content
Tankbuster

sending strings to fnc_initvehicle

Recommended Posts

Guys, I'm struggling with BIS_fnc_initvehicle.
I'm spawning a randomly chosen vehicle, its class name comes from an array and the init line comes from there too.
 

["B_MBT_01_cannon_F","['Sand',1],['showBags',1,'showCamonetTurret',1,'showCamonetHull',1]"]

The script gets the classname and spawns the vehicle, but the vehicle doesn't get the camonet. (it's spawned behind a flying aircraft and has a parachute attached and drifts to the ground if that's relevant)

 

private ["_initresult"];
_cargo= createVehicle [_droptype, (_dropvehactual modelToWorld [0,-25,-10]), [],0,"FLY"];
sleep 1;
if (_initstring isNotEqualTo "") then
{
	_initresult = [_cargo, _initstring] call BIS_fnc_initVehicle;
	diag_log format ["&&&Applied init %1, %2", _initstring, _initresult];
};

 

//17:29:08 "&&&Applied init ['Sand',1],['showBags',1,'showCamonetTurret',1,'showCamonetHull',1], true"

 

Note that if I use the export function from virtual garage and execute that from BIS debug, the vehicle spawns complete with camo net

Share this post


Link to post
Share on other sites
31 minutes ago, Tankbuster said:

but the vehicle doesn't get the camonet.

That's because BIS_fnc_initVehicle doesn't work with string.

Try this code snippet:

if (_initstring isEqualType "") then {
    ([_cargo] + (parseSimpleArray (format ["[%1]", _initstring]))) call BIS_fnc_initVehicle;
};

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

That works. I was never going to stumble across that solution, thank you, brother.
Interesting point, top line of code works, bottom one gives error
 

["B_MBT_01_cannon_F","['Sand',1],['showBags',1,'showCamonetTurret',1,'showCamonetHull',1]"]

['B_MBT_01_cannon_F','["Sand",1],["showBags",1,"showCamonetTurret",1,"showCamonetHull",1]']

 

Share this post


Link to post
Share on other sites

I guess that's because of quotes and apostrophes. Try to invert them.

  • Like 1

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

×