GetPlayerHealth

From SA-MP Wiki

Jump to: navigation, search

GetPlayerHealth


The function GetPlayerHealth allows you to retrieve the health of a player. Useful for cheat detection, among other things.


Parameters:
(playerid, health)
playeridThe ID of the player.
healthValue where the health is stored.


ReturnsThe player's health as a float.


Important Note: Valid player health values in SA-MP are between 0 and 100


// Sets players health to 50 if it was lower than
// 50 before, as soon as he typed /doctor
 
if(strcmp(cmdtext, "/doctor", true) == 0)
{
    new Float:health;
    GetPlayerHealth(playerid,health);
    if (health < 50.0)
    {
        SetPlayerHealth(playerid, 50.0);
    }
    return 1;
}

Related Functions

The following functions might be useful as well, as they're related to this function in one way or another.

Personal tools
In other languages