Jump to content
Sign in to follow this  
Xtri

Problem with some groups stuff.

Recommended Posts

Hello, like I'm having difficulties with a code for groups.

if (isPlayer (leader _x)) then

I'm trying to find out how to get all players in a group instead of just the leader, do you have any tips? I'm kind of new to scripting.

Share this post


Link to post
Share on other sites

You can try:

_players = [];

{
if (isPlayer _x) then {_players set [(count _players),_x]} 
}
foreach (units _x);

or:

_players = [];

{
if (isPlayer _x) then {_players  = _players + [_x]} 
}
foreach (units _x);

so you got, what you want - all players in "_x" group contained inside _players variable. Now you can make such condition:

if ((count _players) > 0) then

But if it is only about condition, if in group is at least one player, or not, then better will be:

_playersCount = {isPlayer _x} count (units _x);

if ((count _playersCount) > 0) then //something

In turn, if you want to do something with each unit, that is a player in that group, then use:

	{
if (isPlayer _x) then {}//do something to him inside this brackets
}
foreach (units _x);

Share this post


Link to post
Share on other sites

Thank you!

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  

×