SetPlayerHealth
From SA-MP Wiki
(Difference between revisions)
| Revision as of 20:55, 3 September 2009 Mikep (Talk | contribs) ← Previous diff |
Current revision BeckzyBoi (Talk | contribs) |
||
| Line 7: | Line 7: | ||
| {{Param|playerid|The ID of the player.}} | {{Param|playerid|The ID of the player.}} | ||
| {{Param|health|New amount of health the player will have.}} | {{Param|health|New amount of health the player will have.}} | ||
| - | |||
| - | {{note2|Health must be an integer not a float, you can get the integer from a float using [[floatround]]. useful when using [[GetPlayerHealth]], which returns a float}} | ||
| {{NoReturn}} | {{NoReturn}} | ||
Current revision
SetPlayerHealth
The function SetPlayerHealth allows you to set the health level of a player.
(playerid, health)
| playerid | The ID of the player. |
| health | New amount of health the player will have. |
This function does not return a specific value, it's best to simply ignore it.
//Sets the players health to full public OnPlayerCommandText(playerid, cmdtext[]) { if(!strcmp("/heal", cmdtext, true)) { SetPlayerHealth(playerid, 100); return 1; } if(!strcmp("/kill", cmdtext, true)) { SetPlayerHealth(playerid, 0); return 1; } return 0; }
Related Functions
The following functions might be useful as well, as they're 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.
