sovietroll 11 Posted September 16, 2013 I am trying to write a script where a group of soldiers can eject out of an aircraft one at a time. Here is the code _squad = _this select 0; //group that to be airdropped _aircraft = _this select 1; //transportation aircraft _squadmember = units _squad; //array of group members _m = 0; //first element in array _n = count _squadmember; //number of group memebers if(_n==3) then {hint "3";}; //debugging purpose //a soldier is ejected every 0.5 second, but the code inside //the while loop only run once. while {_m<_n} do { (_squadmember select _m) action ["EJECT",_aircraft]; player globalChat format["%1",_m]; //debugging purpose sleep 0.5; }; exit; The script is executed with the following line in the trigger [squad,heli] exec "jump.sqf" where "squad" is group of 3 soldiers and "heli" the name of the helicopter However, the code inside the while loop only run once and only one soldier is ejected. It seems the value _m never go above 1. What can possibly go wrong? Share this post Link to post Share on other sites
mr_centipede 31 Posted September 16, 2013 where is _m++? I think that's your problem... that's why _m never get pass 1 Share this post Link to post Share on other sites
sovietroll 11 Posted September 16, 2013 where is _m++? I think that's your problem... that's why _m never get pass 1 I was testing it with for loop so I forgot to add it back. The result is still the same with "_m=_m+1" inside the code. Here is intended code, but it is still not working _squad = _this select 0; //group that to be airdropped _aircraft = _this select 1; //transportation aircraft _squadmember = units _squad; //array of group members _m = 0; //first element in array _n = count _squadmember; //number of group memebers if(_n==3) then {hint "3";}; //debugging purpose //a soldier is ejected every 0.5 second, but the code inside //the while loop only run once. while {_m<_n} do { (_squadmember select _m) action ["EJECT",_aircraft]; _m=_m+1; player globalChat format["%1",_m]; //debugging purpose sleep 0.5; }; exit; Share this post Link to post Share on other sites
sovietroll 11 Posted September 16, 2013 solved. I am not suppose to use exec to execute script. execVM is the right command Share this post Link to post Share on other sites