SetPlayerHealth: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
Line 18: | Line 18: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function slap ( player, command ) --calls the function | function slap ( player, command ) --calls the function | ||
setPlayerHealth ( player, getPlayerHealth - 20 ) --sets the player health | setPlayerHealth ( player, getPlayerHealth(player) - 20 ) --sets the player health | ||
end | end | ||
addCommandHandler ( "slap", slap ) | addCommandHandler ( "slap", slap ) |
Revision as of 07:08, 6 August 2007
This function allows you to set a player's health.
Syntax
bool setPlayerHealth ( player thePlayer, float playerHealth )
Required Arguments
- thePlayer: The player whose health you want to set.
- playerHealth: The value you want to set the health to. Valid values are from 0 (dead) to 100 (full health).
Returns
Returns true if the player's health was set succesfully. Returns false if the player argument is invalid, or the health argument is out of range.
Example
This example finds "player" and when "slap" is entered, their health is decreased
function slap ( player, command ) --calls the function setPlayerHealth ( player, getPlayerHealth(player) - 20 ) --sets the player health end addCommandHandler ( "slap", slap )
See Also
- getPlayerTeam
- getPlayerBlurLevel
- setPlayerBlurLevel
- getPlayerSerial
- forcePlayerMap
- getPlayerScriptDebugLevel
- getPlayerFromName
- getPlayerMoney
- getPlayerName
- getPlayerNametagColor
- getPlayerNametagText
- getPlayerPing
- getPlayerWantedLevel
- givePlayerMoney
- isPlayerMapForced
- isPlayerNametagShowing
- setPlayerHudComponentVisible
- setPlayerMoney
- setPlayerNametagColor
- setPlayerNametagShowing
- setPlayerNametagText
- takePlayerMoney
- countPlayersInTeam
- getPlayersInTeam
- isVoiceEnabled
- setControlState
- getControlState