Jump to content
Sign in to follow this  
bardosy

Set value of a variable by the variable name - help

Recommended Posts

I have a script (sqf) what create a vehicle.

This script has a parameter, the name of the vehicle.

I want name this vehicle after I create it.

 

In Arma2 I could use this:

_plane = createVehicle ["CUP_O_BMP3_RU", _spawnpos, [], 0, "NONE"];
_plane setDir _dir;
_plane setVehicleInit format["%1 = this",_planename];
processInitCommands;

Where the name of the vehicle is _planename.

But in Arma3 there is no setVehicleInit and processInitCommands.

 

How could I name this newly created vehicle?

 

Naming it directly like bmp1=_plane, is not an option, because I will call this script many times with different vehicle names.

And yes, I know I could use this, but it's very ugly:

if (_planename="bmp1") then {
   bmp1 = _plane;
};
if (_planename="bmp2") then {
   bmp2 = _plane;
};
if (_planename="bmp3") then {
   bmp3 = _plane;
};
if (_planename="bmp4") then {
   bmp4 = _plane;
};
...etc

Share this post


Link to post
Share on other sites

Thank you!

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  

×