GetPlayerHealth

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 16:32, 28 October 2013
Badio12 (Talk | contribs)

← Previous diff
Revision as of 22:45, 31 January 2014
Connor Mead (Talk | contribs)

Next diff →
Line 35: Line 35:
[[Category:Scripting_Functions]] [[Category:Scripting_Functions]]
 +[[de:GetPlayerHealth]]
 +[[fr:GetPlayerHealth]]
[[pt:GetPlayerHealth]] [[pt:GetPlayerHealth]]
[[ru:GetPlayerHealth]] [[ru:GetPlayerHealth]]
-[[de:GetPlayerHealth]] 

Revision as of 22:45, 31 January 2014



Description:

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


Parameters:
(playerid, &Float:health)
playeridThe ID of the player.
&Float:healthFloat to store health, passed by reference.


Return Values:

  • 1 - success
  • 0 - failure (i.e. player not connected).
  • The player's health is stored in the specified variable.


// 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 may be useful, as they are related to this function in one way or another.