migueldarius 10 Posted November 6, 2014 Hi Guys, I have a problem with my "Alive Check script", I'm noob in the world of scripting but I try to learn. My problem is that the mission not end when all players dies that mean the mission end lose, so, this script I want work with the revive script BTC, check that all players is dead and end the mission. Please any else to work this script, whats is my fail? Thank you for read, I hope help. :) In Editor Each players or units playable is named P1, P2, P3, P4... etc is for the script work "AliveCheck.sqf" hint "Alive Check Start"; sleep 2; if ( { !(isNull _x) && { !(alive _x) } } count [P1, P2, P3, P4] == 0 ) then { hint "Todos estan muertos o no existen"; }; sleep 2; hint "Alive Check End"; sleep 2; AllPlayersDead = true; "init.sqf" // ***************************** Alive Check Script ************************** AllPlayersDead = false; [] execVM "AliveCheck.sqf"; // ******************************* Revive Script ***************************** enableSaving [false,false]; call compile preprocessFile "=BTC=_revive\=BTC=_revive_init.sqf"; //call compile preprocessFile "=BTC=_revive\lite\=BTC=_revive_init.sqf"; // ******************************** Ends mission ***************************** [] spawn { waitUntil {win}; sleep 1; ["end1", true] call BIS_fnc_endMissionServer; sleep 1; forceEnd; }; [] spawn { waitUntil {AllPlayersDead}; sleep 1; ["LOSER", false] call BIS_fnc_endMissionServer; sleep 1; forceEnd; }; // ******************************* End Init ***************************** Link for the mission: mega.co.nz Share this post Link to post Share on other sites
iceman77 18 Posted November 6, 2014 (edited) If you're having issues ending the mission when all player's are dead while using BTC revive, I would make a post in the official BTC thread. The author will be able to tell you about any BTC related variables that may hold data you need. Other than that, may want to put the AllPlayersDead variable in the scope of the if statement. Unless you want it to be true no matter what, every time you run the script. hint "Alive Check Start"; sleep 2; if (!(isNull _x) && {!(alive _x)} count [P1, P2, P3, P4] == 0 ) then { hint "Todos estan muertos o no existen"; AllPlayersDead = true; }; sleep 2; hint "Alive Check End"; Why not use this as a condition to avoid "naming units"? {( isPlayer _x ) && !( alive _x )} count playableUnits == 0; Edited November 6, 2014 by Iceman77 Share this post Link to post Share on other sites
Wolfenswan 1 Posted November 6, 2014 How does BTC revive work? Does it create new units for the dead ones? I don't see a reason why you wouldn't count the playableUnits array? Also, instead of the two waitUntils you should use a trigger or at least add some sleeps into the waitUntil checks. Otherwise it's wasteful and waitUntils have the nasty habit of carrying over. You could also consolidate those checks into a single one: If either the players win the mission or all die a global variable (let's call it missionOver) flips to true, a trigger registers this change and then shows the correct ending screen, depending on whether > 0 players are still alive. Share this post Link to post Share on other sites
migueldarius 10 Posted November 6, 2014 The problem is not the BTC revive, this work fine, is the script "alive check" that don't check if all players in the same time is dead, I think that i written correctly but dont work... Share this post Link to post Share on other sites
Wolfenswan 1 Posted November 6, 2014 If the player P1 (for example) dies and is revived, does the variable P1 still point to the corpse or the born-again player? As said, using the playableUnits array is probably a better solution. Share this post Link to post Share on other sites
iceman77 18 Posted November 6, 2014 The problem is not the BTC revive, this work fine, is the script "alive check" that don't check if all players in the same time is dead, I think that i written correctly but dont work... Exactly. This is why you should make a post in BTC. The author can give you some insight. Obviously simple alive checks aren't going to work when units are going into and out of conscious / alive states with BTC... Share this post Link to post Share on other sites
migueldarius 10 Posted November 6, 2014 Exactly. This is why you should make a post in BTC. The author can give you some insight. Obviously simple alive checks aren't going to work when units are going into and out of conscious / alive states with BTC... http://forums.bistudio.com/showthread.php?148085-BTC-Revive/page133 Post in, but "playableUnits" dont work too :( Share this post Link to post Share on other sites
iceman77 18 Posted November 6, 2014 It's not about playableUnits (unless you were testing in SP). I could only imagine, but it's probably about BTC throwing units into and out of unconcious /alive / dead states. You did right by posting in the BTC thread. ---------- Post added at 05:18 ---------- Previous post was at 05:15 ---------- try fiddling with lifeState command instead of alive command. Share this post Link to post Share on other sites
migueldarius 10 Posted November 6, 2014 Other cuestion, if in other mission without respawn or revive, only default in the description.ext "respawn = 0;" If i want Check if players is alive, this script maybe work? hint "Alive Check Start"; sleep 2; if ({( isPlayer _x ) && !( alive _x )} count playableUnits == 0 ) then{ hint "All dead or not exist"; }; sleep 2; hint "Alive Check End"; sleep 2; AllPlayersDead = true; Share this post Link to post Share on other sites
iceman77 18 Posted November 6, 2014 Yeah but I'd put your AllPlayersDead variable into the scope of the if statement. Else it will be true every time you check the group's status / run the script, ending your mission pre-matruely. AliveCheck.sqf #1 if (!(isServer)) exitWith {}; hint "Alive Check Start"; sleep 1; if ({( isPlayer _x ) && !( alive _x )} count playableUnits == 0 ) then { hint "All dead or not exist"; AllPlayersDead = true; publicVariable "AllPlayersDead"; }; sleep 1; hint "Alive Check End"; Or simply: if (!(isServer)) exitWith {}; waitUntil { {( isPlayer _x ) && !( alive _x )} count playableUnits == 0 }; hint "All dead or not exist"; AllPlayersDead = true; publicVariable "AllPlayersDead"; Share this post Link to post Share on other sites
migueldarius 10 Posted November 6, 2014 In the original post of BTC Revive, anyone answer me :( ---------- Post added at 15:54 ---------- Previous post was at 15:49 ---------- In the original post of BTC Revive, anyone answer me :( Share this post Link to post Share on other sites