KenniT 0 Posted January 7, 2017 Hello, I have a evacheli that is spawned by this code _crew1 = []; _airframe1 = []; if (isServer) then { _crew1 = creategroup WEST; _airframe1 = [getMarkerPos "evachelispawn", 200, "B_Heli_Transport_01_F", _crew1] call BIS_fnc_spawnVehicle; publicvariable "evacheli"; }; sleep 5; rec = [] spawn Mypath; As you can see I set publicvariable to evacheli and the thing I want to do is for the evacheli to play unitplay after It's spawned but this error pops up '.....983258],[61.4079,39.9577,0.0947061]]]; [|#|evacheli, path1] spawn BIS_fnc_UnitPlay;' Erro Undefined variable in expression: evacheli This is my init Mypath = compile preprocessFile "path.sqf"; [] execVM "briefing.sqf"; This is my path path1 =<random numbers>; [evacheli, path1] spawn BIS_fnc_UnitPlay; This is my trigger with what I activate evacheli.sqf _nul = [this] execVM "evacheli.sqf"; How could i make it work? Thanks! Share this post Link to post Share on other sites
davidoss 550 Posted January 7, 2017 where you have defined evacheli variable? You do not need to define : _crew1 = []; _airframe1 = []; You need to do this only if you want to push something into existing array. 1 Share this post Link to post Share on other sites
KenniT 0 Posted January 7, 2017 39 minutes ago, davidoss said: where you have defined evacheli variable? You do not need to define : _crew1 = []; _airframe1 = []; You need to do this only if you want to push something into existing array. Sorry I'm pretty new to scripting.. :D It doesn't seem to recognize anything that I put into <name> [<name>, path1] spawn BIS_fnc_UnitPlay; I tried _airframe1, _airframe1 and many more Could you give me an example? Thanks! Share this post Link to post Share on other sites
KenniT 0 Posted January 7, 2017 37 minutes ago, davidoss said: where you have defined evacheli variable? You do not need to define : _crew1 = []; _airframe1 = []; You need to do this only if you want to push something into existing array. Sorry I'm pretty new to scripting.. :D It doesn't seem to recognize anything that I put into <name> [<name>, path1] spawn BIS_fnc_UnitPlay; I tried _airframe1, _airframe1 and many more Could you give me an example? Thanks! Share this post Link to post Share on other sites
theend3r 83 Posted January 7, 2017 2 minutes ago, KenniT said: Sorry I'm pretty new to scripting.. :D It doesn't seem to recognize anything that I put into <name> [<name>, path1] spawn BIS_fnc_UnitPlay; I tried _airframe1, _airframe1 and many more Could you give me an example? Thanks! The question is, does a unit named evacheli exist when the script executes? Share this post Link to post Share on other sites
davidoss 550 Posted January 7, 2017 most every commands/ called functions is returning something. This will be stored under variable which is defined as result. In your case, _crew1 = creategroup WEST; in _crew1 will be stored the created group or grpNull if fails, but there is the cutch. You really do not need do that because the next line can do this automatically. _airframe1 = [getMarkerPos "evachelispawn", 200, "B_Heli_Transport_01_F", WEST] call BIS_fnc_spawnVehicle; in _airframe1 will be stored an array with 3 indexes: 0: created vehicle (Object), 1: all crew (Array of Objects), 2: vehicle's group (Group) So in your case: if (isServer) then { _airframe1 = [getMarkerPos "evachelispawn", 200, "B_Heli_Transport_01_F", WEST] call BIS_fnc_spawnVehicle; _heli = _airframe1 select 0; //commented out if not needed //_helicrew = _airframe1 select 1; //_heligroup = _airframe1 select 2; _heli setVehicleVarName "evacheli"; evacheli = _heli; publicvariable "evacheli"; }; Is very hard to give the right example because there are lots of unknowns in your posted snippets. For example : do you need the _heli variable in your code? If not you can just define evacheli instead. Do you really need to public variable evacheli? You need to knew that. Always refer to WIKI for used commands and functions to have knowledge what they returns or what you need to pass into it. Do your BIS_fnc_UnitPlay needs a pilot of your heli or it can be just heli vehicle itself. Check that on your own Share this post Link to post Share on other sites
KenniT 0 Posted January 7, 2017 15 minutes ago, davidoss said: most every commands/ called functions is returning something. This will be stored under variable which is defined as result. In your case, _crew1 = creategroup WEST; in _crew1 will be stored the created group or grpNull if fails, but there is the cutch. You really do not need do that because the next line can do this automatically. _airframe1 = [getMarkerPos "evachelispawn", 200, "B_Heli_Transport_01_F", WEST] call BIS_fnc_spawnVehicle; in _airframe1 will be stored an array with 3 indexes: 0: created vehicle (Object), 1: all crew (Array of Objects), 2: vehicle's group (Group) So in your case: if (isServer) then { _airframe1 = [getMarkerPos "evachelispawn", 200, "B_Heli_Transport_01_F", WEST] call BIS_fnc_spawnVehicle; _heli = _airframe1 select 0; //commented out if not needed //_helicrew = _airframe1 select 1; //_heligroup = _airframe1 select 2; _heli setVehicleVarname "evacheli"; evacheli = _heli; publicvariable "evacheli"; }; Thank you! Share this post Link to post Share on other sites