OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Rommel92 on 02 Jun 2008, 05:39:19

Title: Count Units Gorup
Post by: Rommel92 on 02 Jun 2008, 05:39:19
Code: [Select]
_grp = _this select 0;

while {count units _grp > 0} do
{
sleep 1.0;
player globalchat format["%1",count units _grp];
};

9 civilians in the editor (in a group). I shoot one, about 7 seconds later I hear them call out "OH NO... 5 IS DOWN". Then the counter drops down to 8... is there any instantaneous way to check groups for sizes?

Code: [Select]
_grp = _this select 0;
_counter = 0;
{if (alive _x) then {_counter = _counter + 1};} forEach units _group;

while {true} do
{
sleep 1.0;
_counter = 0;
{if (alive _x) then {_counter = _counter + 1};} forEach units _group;
player globalchat format["%1",count units _grp];
};

Even this does not work too well, there is a large gap between "alive" and "dead" notions, and it can take up to 20 seconds for the game to realise that there is 0 units left in the group.
Title: Re: Count Units Gorup
Post by: Mandoble on 02 Jun 2008, 08:01:58
Your global chat is not showing _counter but count units _grp
You might also use a simpler way to count them:
Code: [Select]
{alive _x} count units _grp
Title: Re: Count Units Gorup
Post by: Rommel92 on 02 Jun 2008, 08:11:10
I'm a tool. Thanks Mando.  :good:

Title: Re: Count Units Gorup
Post by: Wolfrug on 02 Jun 2008, 15:17:34
Note that this isn't the game noticing anything : it's the squad leader! Using count units group will yield the SUPPOSED amount of units alive in the group, not the actual. Sort of like when you've positioned a guy somewhere far far off out of sight, and he gets wasted by a spetznatz, you won't actually know about it (and your group indicator at the bottom will still show him as alive and well). Can be used for all kinds of of situations where you don't need precise data, but supposed  :good:

Otherwise use the {alive _X} suggestion, yes.

Wolfrug out.