FR-Helios 28 Posted January 19, 2016 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 Posted January 19, 2016 Why don't you use a Killed EH ? Share this post Link to post Share on other sites
FR-Helios 28 Posted January 19, 2016 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
whiztler 137 Posted January 19, 2016 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
barbolani 198 Posted January 19, 2016 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
FR-Helios 28 Posted January 19, 2016 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