Take care when using count to determine how many units are left alive in a group: count units groupplayer or count units groupname Will return the number of units the leader of the group thinks are alive. If some units have been killed out of sight of other members of the group then it may take sometime for this to be the actual numbers in the group. To determine exactly how many units are really alive in a group use:
This code will exit the count loop as soon as it finds an element fulfilling the condition, leaving the count with the value of 1, hence make the larger if-condition be true.
If no array element fulfills the condition, the count will be 0 and the if-condition will be false.
Killzone_Kid
Quit loop at first fulfilled condition (same as above but faster):
{
if (_x == 4) exitWith {
// do something when we reach 4
}
} count [1,2,3,4,5,6];
Heeeere's Johnny!
Using exitWith inside a count loop will overwrite the default functionality and make count return whatever the exitWith returns: