R4IDER 10 Posted December 19, 2013 Hi, I am trying to work out how to delete units from certain groups. I am using this to spawn a unit. _ParaGroup1 = CreateGroup EAST; _soldier = _ParaGroup1 createUnit ["O_SD_Soldier",(GetMarkerPos "paraspawn1"),[],0,"sergeant"]; _soldier = _ParaGroup1 createUnit ["O_SD_Soldier",(GetMarkerPos "paraspawn1"),[],0,"private"]; If this group doesn't get killed then later on down the line I would like to delete them so their not using up server CPU cycles. What I am trying to do is store all of the groups I would like to delete in an array then loop through the array and delete each group, I am not seeing any errors when I run this which is odd so its either running and not doing what I want it to do or I have done something terrible and its not even running. _groups = [_ParaGroup1,_ParaGroup2,_ParaGroup3,_ParaGroup4,_GroupFourB_X,_GroupFourC_X]; _loop = 0; { _group = _groups select _loop; _loop = _loop + 1; { deleteVehicle _x } forEach units group _group; deleteGroup _group; } forEach _groups; As you can see I have two loops one for each group in my array and one for each unit in the group. Could anyone tell me what I am doing or maybe show me a better way of doing this? Share this post Link to post Share on other sites
mariodu62 5 Posted December 19, 2013 (edited) _groups = [_ParaGroup1,_ParaGroup2,_ParaGroup3,_ParaGroup4,_GroupFourB_X,_GroupFourC_X]; { _group = _x ; { deleteVehicle _x ; } forEach units _group; deleteGroup _group; } forEach _groups; Edited December 19, 2013 by Mariodu62 1 Share this post Link to post Share on other sites
mad_cheese 593 Posted December 19, 2013 You are spawning and deleting within the same script, right? _groups = [_ParaGroup1,_ParaGroup2]; for "_i" from 0 to ((count _groups)-1) do { {deletevehicle _x} foreach units (_groups select _i); deletegroup (_groups select _i); }; Share this post Link to post Share on other sites
R4IDER 10 Posted December 19, 2013 _groups = [_ParaGroup1,_ParaGroup2,_ParaGroup3,_ParaGroup4,_GroupFourB_X,_GroupFourC_X]; { _group = _x ; { deleteVehicle _x ; } forEach units _group; deleteGroup _group; } forEach _groups; Thank you for your help. @ Mad_Cheese Yes, I am using triggers and trigger conditions I am spawning required units all from one script file. So basically once a player enters the area1 trigger I am running area1=true; in my act. This then activates another trigger with the condition area1 and the act runs the script file. In my script file I am using if(area1) then { if isNil {area1spawned} then { My spawn code area1spawned=true; publicVariable "area1spawned"; } else { publicVariable "area1spawned"; }; I am not sure if I really need that else in there I just figured it would then sync up any JIP players each time the script is ran. Share this post Link to post Share on other sites