Jump to content
Rogu3 H1Z1Stakes.com

Check if all unit 'west' is dead, if so do x

Recommended Posts

Hello, so i am trying to figure out the code behind checking whether or not an entire unit is dead

Here is the code i tried but didn't have no success

players = allPlayers;

{
    if(side _x == west) then
    {
        //Exectute code for all dead.
    }
} foreach _players allDead;

 

can anyone help me?

Share this post


Link to post
Share on other sites
_westPlayers = allPlayers select {side _x == west};//Returns all players of side west.

_aliveDeadPlayers = _westPlayers count {alive _x};//Returns how many west players are alive. Will be 0 if all are dead.

 

Share this post


Link to post
Share on other sites
5 hours ago, Dedmen said:

_westPlayers = allPlayers select {side _x == west};//Returns all players of side west.

_aliveDeadPlayers = _westPlayers count {alive _x};//Returns how many west players are alive. Will be 0 if all are dead.

 

Maybe an oversight, the correct syntax would be:

_aliveDeadPlayers = {alive _x} count _westPlayers;

Cheers

  • Thanks 1

Share this post


Link to post
Share on other sites

?

_westCount = allPlayers select {side _x == west && alive _x};
if (count _westCount == 0) then
{
	hint "dey dead";
};

 

Share this post


Link to post
Share on other sites
10 hours ago, Dedmen said:

_westPlayers = allPlayers select {side _x == west};//Returns all players of side west.

_aliveDeadPlayers = _westPlayers count {alive _x};//Returns how many west players are alive. Will be 0 if all are dead.

These will both be the same, as a dead players side is CIV no matter their original side.

 

if ( count( allPlayers select{side _x == west} ) == 0 ) then {
	hint "West are all dead";
};

 

Share this post


Link to post
Share on other sites
44 minutes ago, Larrow said:

These will both be the same, as a dead players side is CIV no matter their original side.

 


if ( count( allPlayers select{side _x == west} ) == 0 ) then {
	hint "West are all dead";
};

 

i thought that was just AI that turned to civ upon death?

Share this post


Link to post
Share on other sites
On 5/30/2018 at 7:50 PM, gokitty1199 said:

i thought that was just AI that turned to civ upon death?

No, player units do as well. Test it out in a quick 2 player hosted from the editor, with...

allPlayers apply{ side _x }

In a watch line in the debug console. As soon as you shoot the other player you will see CIV in the list. Once he respawns it will be back to WEST.

 

You could just do...

if ( west countSide allPlayers isEqualTo 0 ) then {
    hint "All west players are dead";
};

 

  • Like 2

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

×