pcc 14 Posted September 11, 2011 I'm trying to eject dead crews from their vehicles. Here's what I have so far but its not working. while {true} do { crew = _this select 0; if (crew not alive) then { unassignVehicle (_x); (_x) action ["eject", vehicle _x]; //sleep 1; } foreach units crew; }; What am I doing wrong? Share this post Link to post Share on other sites
twirly 11 Posted September 11, 2011 Hi mate... Where are you putting that code? Share this post Link to post Share on other sites
DAP 619 Posted September 11, 2011 (edited) while {true} do { [color="Red"][b]_vehicle[/b][/color] = _this select 0; [i]- this is vehicle with assigned script (this)[/i] [indent][color="Red"][b]_crew = crew _vehicle;[/b][/color][/indent] if [b][color="Red"](!(alive _crew))[/color][/b] then { unassignVehicle (_x); [color="Red"][b](_x) setPos (getPos (vehicle _x));[/b][/color] //sleep 1; } foreach [color="Red"][b]_crew[/b][/color]; [b]sleep 1;[/b] }; Edited September 11, 2011 by DAP Share this post Link to post Share on other sites
neokika 62 Posted September 11, 2011 You got the sctructure all wrong. _veh = TAG_someVehicle; while {true} do { { _x action ["eject", vehicle _x]; //Will this work with dead units? } foreach (crew _veh); sleep 1; }; _neo_ Share this post Link to post Share on other sites
KC Grimes 79 Posted September 11, 2011 Do actions work for dead units? Does crew even pick up dead units? Share this post Link to post Share on other sites
pcc 14 Posted September 11, 2011 @twirly I saved it in eject.sqf and put [] execVM "eject.sqf"; in the init.sqf. @DAP _vehicle = _this select 0; - this is vehicle with assigned script (this) How do I assign it to all vehicles spawned in the game? Share this post Link to post Share on other sites
KC Grimes 79 Posted September 11, 2011 What DAP is doing would require you to execute eject.sqf through the vehicle init, not init.sqf. _this would represent the vehicle who's init its in. Basically, if you're going to use DAPs method, just exec eject.sqf through every vehicle's init. Share this post Link to post Share on other sites
pcc 14 Posted September 11, 2011 I'm using this for warfare and vehicles are spawned by factories, so I can't put it in the vehicle's init. How can I make it work with init.sqf? Share this post Link to post Share on other sites
twirly 11 Posted September 11, 2011 (edited) It seems the eject action doesn't work on dead units....so DAP is correct with using setpos instead of eject. Don't know much about Warfare.... but somehow you have to find where the vehicle is created in the code and modify it. Run the script with:- nul = [[b]_vehicle_created_by_warfare[/b]] execVM "eject.sqf"; eject.sqf:- private ["_veh","_run","_crew"]; _veh = _this select 0; _run = true; while {_run} do { _crew = crew _veh; if ({alive _x} count (crew _veh) == 0) then { {_x setpos getpos _veh} foreach crew _veh; _run =false; }; sleep 1; }; The above code runs until everyone in the vehicle is dead and then exits....this (below) will run as long as the vehicle is alive. eject.sqf:- private ["_veh","_crew"]; _veh = _this select 0; while {alive _veh} do { _crew = crew _veh; if ({alive _x} count (crew _veh) == 0) then { {_x setpos getpos _veh} foreach crew _veh; }; sleep 1; }; Edited September 11, 2011 by twirly Share this post Link to post Share on other sites
pcc 14 Posted September 12, 2011 Thanks for all the help. Share this post Link to post Share on other sites