SA-MP Forums Archive
recover between all the players which has the highest health - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: recover between all the players which has the highest health (/showthread.php?tid=213982)



recover between all the players which has the highest health - vardanega - 20.01.2011

and any question! how to recover from all the players who has the highest health

Thanks !


AW: recover between all the players which has the highest health - NuggaN_ - 20.01.2011

So you want recover it by connecting? (When he disconnected it should save the hp he had and by connecting it should load?


Re: recover between all the players which has the highest health - woot - 20.01.2011

I guess you wanna get the player id which has the most health .. I guess something like this should work;

pawn Код:
stock returnHighestHealthID()
{
    new Float:_health[2], pMost = INVALID_PLAYER_ID;
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i) || IsPlayerNPC(i)) continue;
        GetPlayerHealth(i, _health[0]);
        if(_health[0] > _health[1]) pMost = i, _health[1] = _health[0];    
    }
    return pMost;
}



- viKKmaN - 20.01.2011

pawn Код:
stock GETHHPPlayerID()
{
     new Float:phealth, Float:chealth, pid = INVALID_PLAYER_ID;
     for(new i=0; i<GetMaxPlayers(); i++)
     {
          if(!IsPlayerConnected(i)) continue;
          GetPlayerHealth(playerid, chealth);
          if(chealth > phealth) phealth = chealth, pid = i;
     }
     return pid;
}



Re : recover between all the players which has the highest health - vardanega - 20.01.2011

Thanks !