Alpine_gremlin 13 Posted April 18, 2019 Hey guys its been a while since I`ve written any code for ArmA so I`m super rusty. Using the ACE mod, I`m trying to make it so that after an individual player dies twice, they are transferred to the spectator screen. The code seems really simple, so I`m not sure why it isn`t working. I`m not getting any script errors so is it just bad syntax? "handleSpectator.sqf" is called via initPlayerLocal.sqf: [[west], [east,civilian]] call ace_spectator_fnc_updateSides; [[0,1,2], []] call ace_spectator_fnc_updateCameraModes; [[], [allPlayers]] call ace_spectator_fnc_updateUnits; hint "First Life..."; waitUntil {!alive player}; sleep 5; hint "Second Life..."; waitUntil {!alive player}; [true] call ace_spectator_fnc_setSpectator; Share this post Link to post Share on other sites
stanhope 409 Posted April 19, 2019 I'd use something along the lines of private _lifeNumber = profileNameSpace getVarible ["SomeUniqueVariableName", 0]; _lifeNumber = _lifeNumber + 1; if ( _lifeNumber > 2) then { [true] call ace_spectator_fnc_setSpectator; } else { profileNameSpace setVariable ["SomeUniqueVariableName", _lifeNumber ]; hint format ["Life number %1", _lifeNumber]; }; in OnPlayerRespawn. (Untested) An alternative to a var in profilenamespace could be a global variable. 1 Share this post Link to post Share on other sites
Alpine_gremlin 13 Posted April 19, 2019 Do you use profileNameSpace to keep track of _lifenumber as its value applies to the player? Share this post Link to post Share on other sites
stanhope 409 Posted April 19, 2019 That piece of code does the following: It goes to a players profilenamespace and fetches the variable with a given name. If this variable does not exist it uses 0 as a default value. It puts that value into _lifenumber. Once that's done it adds 1 to this value. Then it checks whether or not that value is greater than 2. If it is that ace function is called. If not the new value is stored in the profilenamespace so next time a player respawns when we fetch that variable again it'll be 1 higher than this time. Hope that helps. 1 Share this post Link to post Share on other sites
Alpine_gremlin 13 Posted April 20, 2019 Thank you that makes perfect sense @stanhope! Share this post Link to post Share on other sites
stanhope 409 Posted April 20, 2019 Oh I forgot to mention this: put <profileNameSpace setVariable ["SomeUniqueVariableName", nil];> into initplayerlocal. Otherwise that number will be persistent over several game sessions. Share this post Link to post Share on other sites
Alpine_gremlin 13 Posted April 21, 2019 7 hours ago, stanhope said: Oh I forgot to mention this: put <profileNameSpace setVariable ["SomeUniqueVariableName", nil];> into initplayerlocal. Otherwise that number will be persistent over several game sessions. Understood. Thank you! Share this post Link to post Share on other sites