SA-MP Forums Archive
Is Player Alive - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Is Player Alive (/showthread.php?tid=628293)



Is Player Alive - aoky - 08.02.2017

Hey guys! Is there anyway to check if a player is alive? In my current script when a player gets hit by a dildo, he gets put into spectate mode. He spectates the person with the dildo(AKA Slapper), so I'd want to know if it's possible to make a textdraw to say how much players are alive. I would appreciate any help!


TLR: Is there anyway to make a textdraw to say "Fappers alive: X". When a player gets hit by a dildo he spectates the Slapper. Thank you!


Re: Is Player Alive - Vince - 08.02.2017

Option 1: use a custom foreach iterator to store alive players and then use Iter_Count. Option 2: do a manual loop over all the players and increment a counter if the state of the player is not "wasted" or "spectating".


Re: Is Player Alive - YouHack - 19.05.2017

PHP код:
new Alive 0;
public 
OnPlayerConnect(playerid)
{
    
Alive++; // if you want to set player as alive when he joins
}
public 
OnPlayerStateChange(playeridnewstateoldstate)
{
    if(
newstate == PLAYER_STATE_WASTED || PLAYER_STATE_SPECTATING) { Alive++; }
    else if(
newstate == !(PLAYER_STATE_WASTED || PLAYER_STATE_SPECTATING)) { Alive--; }
    return 
1;
}
// use Alive variable in textdraw ^^ 



Re: Is Player Alive - CheezIt - 20.05.2017

Have a global variable, and when the player joins the event or spawns increase the variable by 1. When a player leaves the event or gets slapped, decrease the variable. Simple as that.