SetPlayerHealth
Description:
Function SetPlayerHealth set the health of a player.
|
Health is obtained rounded to integers: set 50.15, but get 50.0 |
Parameters:
(playerid, Float:health)
int | playerid | The ID of the player to set the health of. |
float | health | The value to set the player's health to. Max health that can be displayed in the HUD is 100, though higher values are valid. |
Return Values:
- 1: The function was executed successfully.
- 0: The function failed to execute. This means the player specified does not exist.
Examples:
//Sets the players health to full public OnPlayerCommandText(playerid, cmdtext[]) { if(!strcmp("/heal", cmdtext, true)) { SetPlayerHealth(playerid, 100.0); return 1; } if(!strcmp("/kill", cmdtext, true)) { SetPlayerHealth(playerid, 0.0); return 1; } return 0; }
Related Functions
The following functions may be useful, as they are related to this function in one way or another.
- GetPlayerHealth: Find out how much health a player has.
- GetPlayerArmour: Find out how much armour a player has.
- SetPlayerArmour: Set the armour of a player.