Jump to content
Sign in to follow this  
FR-Helios

Count players and count players wounded

Recommended Posts

Hello guy!

 

I prepare a cooperation mission with a script who launch "end mission" when all players connected are a variable "btc_qr_unc".

 

Launch in init.sqf

null = [] execVM "Scripts\EndFailed.sqf";

EndFailed.sqf:

//All Players Dead

    chk_dead = {
{
        _playerCount = 0;
        _downCount = 0;
        {
            if (isPlayer _x)
            then {_playerCount = _playerCount +1;
                    if (_x getVariable "btc_qr_unc")
                    then {_downCount = _downCount +1;sleep 1}
                };
        };
} forEach units SealTeam;
        
        if (_downCount == _playerCount)
        then {ENDFAILED2 = true};
                };

    [] spawn
        {
            while{true} do
            {
                sleep 10;
                [] spawn chk_dead;
            };
        };

It doesn't works, anyone can help me?

 

Share this post


Link to post
Share on other sites
Guest

Why don't you use a Killed EH ?

Share this post


Link to post
Share on other sites

Why don't you use a Killed EH ?

I don't wish that. I need to understand what doesn't works in my script.

Share this post


Link to post
Share on other sites

You had a bracket mismatch. I suggest you enble -showScripterrors and use an editor that enables you to tracks you (closing) brackets:

chk_dead = {
	{
		_playerCount = 0;
		_downCount = 0;
		
		if (isPlayer _x) then {
			_playerCount = _playerCount +1;
			if (_x getVariable "btc_qr_unc") then {
				_downCount = _downCount +1;
				sleep 1
			};
		};

	} forEach units SealTeam;

	if (_downCount == _playerCount) then {
		ENDFAILED2 = true
	};
	
	[] spawn {
		while {true} do {
			sleep 10;
			[] spawn chk_dead;
		};
	};
};

Also, when checking a variable, it is wise to define a default value:

if (_x getVariable ["btc_qr_unc", true]) then {

Share this post


Link to post
Share on other sites

And this?

 

{_x getVariable ["btc_qr_unc", true]} count playableUnits == count playableUnits;

 

If I understand, you want to end mission when all the players are in the unconscious state set by BTC revive.

Share this post


Link to post
Share on other sites

And this?

 

{_x getVariable ["btc_qr_unc", true]} count playableUnits == count playableUnits;

 

If I understand, you want to end mission when all the players are in the unconscious state set by BTC revive.

Exactly :)

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  

×