Is Player Alive
#1

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!
Reply
#2

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".
Reply
#3

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 ^^ 
Reply
#4

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)