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=445263)



Is Player Alive ? - Champ - 20.06.2013

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.


Re: Is Player Alive ? - trukker1998 - 20.06.2013

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.


Re: Is Player Alive ? - Champ - 20.06.2013

I don't want to kick him. I just want a function that finds the player and name that player in the chat.


Re: Is Player Alive ? - XSR - 20.06.2013

Код:
new Float:health;
GetPlayerHealth( playerid,health );
if ( health >= 0.0 ) 
{
    SetClientMessage( playerid, -1, "Player is alive!!!" );
}



Re: Is Player Alive ? - rpg894 - 20.06.2013

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.


Re: Is Player Alive ? - Excel™ - 20.06.2013

try this:

pawn Код:
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;
}



Re: Is Player Alive ? - TheOnlyRealFuzzy - 20.06.2013

Quote:
Originally Posted by Excel™
Посмотреть сообщение
try this:
pawn Код:
SetTimerEx("OnServerUpdate", 1, true);
You cannot be serious.


Re: Is Player Alive ? - Excel™ - 20.06.2013

Quote:
Originally Posted by TheOnlyRealFuzzy
Посмотреть сообщение
You cannot be serious.
Whats the problem in this ?


Re: Is Player Alive ? - Niko_boy - 20.06.2013

Quote:
Originally Posted by Excel™
Посмотреть сообщение
Whats the problem in this ?
dude why someone will need a 1 milli second timer for this purpose ..


Re: Is Player Alive ? - TheOnlyRealFuzzy - 20.06.2013

Quote:
Originally Posted by Excel™
Посмотреть сообщение
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?