wyattwic 38 Posted December 25, 2015 Hello everyone, I have been having a hard time figuring out the best way of removing dead units from a trigger. So far, what would seem the simplest and correct way to go has proven intermittent, along with other attempts. Currently, the best I have been able to come up with was to have the server execute the following code. The results were intermittent, only working 75% of the time. "Base" is a trigger set with "this" as a condition on repetitive. while {true} do { {if !(alive _x) then {deleteVehicle _x}} foreach list Base; }; Any ideas or suggestions would be loved! Thank you. Share this post Link to post Share on other sites
davidoss 528 Posted December 25, 2015 Dead vehicles or dead units? Share this post Link to post Share on other sites
wyattwic 38 Posted December 25, 2015 Both preferably but vehicles are what I need taken care of the most. Share this post Link to post Share on other sites
davidoss 528 Posted December 25, 2015 This will delete all dead man and all wrecks every 100 sec [] spawn { while {true} do { {deleteVehicle _x} forEach allDeadMen; {if (damage _x == 1) then { deleteVehicle _x};} forEach vehicles; sleep 100; }; }; If you want only for specific trigger or marker zone //Base = trigger name, if marker use "markername" [] spawn { while {true} do { {if ([Base, _x] call BIS_fnc_inTrigger) then {deleteVehicle _x};} forEach allDeadMen; {if (damage _x == 1 && ([Base, _x] call BIS_fnc_inTrigger)) then { deleteVehicle _x};} forEach vehicles; sleep 100; }; }; Share this post Link to post Share on other sites
wyattwic 38 Posted December 25, 2015 Is there any way to restrict it by location? This appears to do all destroyed vehicles and people. Thank you EDIT: Solved it! Thank you! while {true} do { {deleteVehicle _x} forEach allDeadMen in list Base; {if (damage _x == 1) then { deleteVehicle _x};} forEach vehicles in list Base; sleep 10; }; Share this post Link to post Share on other sites
wyattwic 38 Posted December 25, 2015 Okay, forget that edit. Both of our iterations of the script target all wrecks. Any ideas? Share this post Link to post Share on other sites
davidoss 528 Posted December 25, 2015 If you want only for specific trigger or marker zone //Base = trigger name, if marker use "markername" [] spawn { while {true} do { {if ([Base, _x] call BIS_fnc_inTrigger) then {deleteVehicle _x};} forEach allDeadMen; {if (damage _x == 1 && ([Base, _x] call BIS_fnc_inTrigger)) then { deleteVehicle _x};} forEach vehicles; sleep 100; }; }; Share this post Link to post Share on other sites
wyattwic 38 Posted December 25, 2015 Found the problem! while {true} do { {if (damage _x == 1) then {deleteVehicle _x}} foreach list Base; }; This code works flawlessly. Now my only question is, do you think there is much of a drawback of not having a wait in there? Share this post Link to post Share on other sites
wyattwic 38 Posted December 25, 2015 If you want only for specific trigger or marker zone //Base = trigger name, if marker use "markername" [] spawn { while {true} do { {if ([Base, _x] call BIS_fnc_inTrigger) then {deleteVehicle _x};} forEach allDeadMen; {if (damage _x == 1 && ([Base, _x] call BIS_fnc_inTrigger)) then { deleteVehicle _x};} forEach vehicles; sleep 100; }; }; Im gonna give this method a try. Both will probably work, but the question is, assuming we have identical sleeps, witch one consumes more resources? Share this post Link to post Share on other sites
whiztler 128 Posted December 25, 2015 . This code works flawlessly. Now my only question is, do you think there is much of a drawback of not having a wait in there? Yes, you def want to have a sleep in there. Also you might want to add a min player distance as it might break immersion if destroyed vehicles are removed before their eyes. Share this post Link to post Share on other sites
wyattwic 38 Posted December 25, 2015 My version of the code has proven to be intermittent again... Sigh. Your version of the code is working excellent so far. Thank you very much! Share this post Link to post Share on other sites
wyattwic 38 Posted December 25, 2015 . Yes, you def want to have a sleep in there. Also you might want to add a min player distance as it might break immersion if destroyed vehicles are removed before their eyes. Thanks for the suggestion. The main reason why I am putting this on a base trigger though, is a-holes seem to love to jump in helicopters ram the base on a COOP mission. Share this post Link to post Share on other sites
wyattwic 38 Posted December 25, 2015 If you want only for specific trigger or marker zone //Base = trigger name, if marker use "markername" [] spawn { while {true} do { {if ([Base, _x] call BIS_fnc_inTrigger) then {deleteVehicle _x};} forEach allDeadMen; {if (damage _x == 1 && ([Base, _x] call BIS_fnc_inTrigger)) then { deleteVehicle _x};} forEach vehicles; sleep 100; }; }; This variant of the code is working flawlessly so far after slaughtering hundreds of tanks, aircraft and soldiers. So I can understand things a bit better, do you have an idea as to why my code was intermittent and yours was solid? In essence they are asking for the same thing, given that damage = 1 is the same as not being alive, right? 1 Share this post Link to post Share on other sites
killzone_kid 1222 Posted December 25, 2015 Found the problem! while {true} do { {if (damage _x == 1) then {deleteVehicle _x}} foreach list Base; }; This code works flawlessly. Now my only question is, do you think there is much of a drawback of not having a wait in there? It shouldn't work at all, dead vehicles are excluded from detected vehicles therefore excluded from list Share this post Link to post Share on other sites