PDA

View Full Version : Is Player Alive ?


Champ
20/06/2013, 03:37 PM
Is there any function which tells that is there any player alive in the server. I mean in "no respawn dm" all players are dead and wins only one player who is still alive.

trukker1998
20/06/2013, 03:42 PM
You can kick them out of your DM when they are in a minigame or something, just check if PlayerHealth is arround 0 or 0.

Champ
20/06/2013, 03:51 PM
I don't want to kick him. I just want a function that finds the player and name that player in the chat.

XSR
20/06/2013, 03:55 PM
new Float:health;
GetPlayerHealth( playerid,health );
if ( health >= 0.0 )
{
SetClientMessage( playerid, -1, "Player is alive!!!" );
}

rpg894
20/06/2013, 03:56 PM
pakistan barbarian you have grass instead of brain. use a loop and a variable to check if player is in dm. To count how many players are in dm use another variable which you increase it ++ on each loop. And it starts from 0, if this variable goes to 1 means only one player alive in dm.

Excel™
20/06/2013, 03:58 PM
try this:


SetTimerEx("OnServerUpdate", 1, true);

public OnServerUpdate()
{
new count=0;
for(new i; i < MAX_PLAYERS; i++)
{
new Float:hp;
GetPlayerHealth(i, hp);
if(hp > 1.0)
{ count++; }
}
if(count > 1)
{
// DO your coding here
}
//if you need this code i mentioned above, so for your info. this will detect if there is only one player alive
if(count == 1)
{
// DO your coding here
}
return 1;
}

Ballu Miaa
20/06/2013, 04:05 PM
In simple words "You need to check that player has more then 1 hp. That means he is alive. Thats all dude.

Champ
20/06/2013, 04:30 PM
Thank you Guyzz ! I was a little confused.

TheOnlyRealFuzzy
20/06/2013, 04:33 PM
try this:

SetTimerEx("OnServerUpdate", 1, true);

You cannot be serious.

Niko_boy
20/06/2013, 04:43 PM
wouldnt player state also help to solve same purpose ?
if( GetPlayerState(playerid) == PLAYER_STATE_WASTED ) // means dead , or in class selection , or
if( GetPlayerState(playerid) != PLAYER_STATE_SPAWNED ) // means either spec or not spawned ( dead or class )
anyways better would be assign a variable like:
PlayerAlive[playerid] , make it false in OnPLayerDeath

Excel™
20/06/2013, 04:56 PM
You cannot be serious.

Whats the problem in this ?

Niko_boy
20/06/2013, 05:00 PM
Whats the problem in this ?

dude why someone will need a 1 milli second timer for this purpose ..

TheOnlyRealFuzzy
20/06/2013, 06:50 PM
Whats the problem in this ?
That will be called 1000 times in a second? 10000 times in 10 seconds. 60000 times in a minute, you see any problem with performance maybe here?

BigETI
20/06/2013, 06:54 PM
Once a player has triggered OnPlayerDeath, you can set a variable for them and make them spectators.
Check, if there is only a single player, who has been not set yet, and make him winner, using a player loop in OnPlayerDeath.
Pretty much simple!