Jump to content
Sign in to follow this  
igneous01

count all empty groups? (groups with no members alive in them)

Recommended Posts

I want to figure out how to count all groups that have no living members in them, and then delete them. I searched and surprisingly nothing came up about this.

From what i know, even if an entire squad gets killed, the group still exists, and when lets say dynamically spawning units, i want to make sure my script doesnt go overboard with the amount of groups made.

So far i have this in theory:

count !alive units allgroups

in theory thats what i want, but i dont know how to implement it

Share this post


Link to post
Share on other sites

something like this maybe:

{if (({alive _x} count units _x) == 0) then {deleteGroup _x}} foreach allGroups;

Share this post


Link to post
Share on other sites

Where would I need to put this code to make it work

keeping in mind it would be on a dedicated server - can I just paste it into the init.sqf?

{if (({alive _x} count units _x) == 0) then {deleteGroup _x}} foreach allGroups;

Cheers in advance

Share this post


Link to post
Share on other sites

place this in init.sqf, it will check every 5 seconds and delete empty groups for the duration of the mission:

while {true} do {
  {if (({alive _x} count units _x) == 0) then {deleteGroup _x}} foreach allGroups; 
  sleep 5;
};

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×