Jump to content
Sign in to follow this  
chrisyou

Counting PLAYED units

Recommended Posts

Heya guys.

Ive got 19 units placed in my mp mission.

I wanna count how many of them are used..

I am not exactly new to scripting but this bothered me for quite some time..

west countSide allUnits returns 19.

west countSide playableUnits returns 18.

How do I count how many of them are ACTUALLY played?

Thanks a lot guys.. If you need me to explain my situation a little further, go ahead and ask. :)

Best Regards

chrisyou

Share this post


Link to post
Share on other sites

_players = 0;
_unitlist = [] + allUnits + allDead;
{if (isplayer _x) then {_players = _players +1}} forEach _unitlist;
hintsilent format ["There are currently %1 human players.", _players];

Not sure whether the allDead-stuff works...

Edited by RogueTrooper

Share this post


Link to post
Share on other sites

Thank you RogueTrooper. I already found my own solution. Stupid post by me :(

Here is it for anyone wondering.

_count = 0;
{
if((isPLayer _x) && (side _x == west)) then {
_count = _count + 1
};
} forEach playableUnits;
hint format["%1 west units",_count];

Share this post


Link to post
Share on other sites

You could just use COUNT instead of countSide or foreach with a counter.

hint format["%1 west players", {isPlayer _x && side _x == west}count playableUnits];

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  

×