Gamemode.PlayerHurt

From GMod Wiki

Jump to: navigation, search
Event Hook
Hook NamePlayerHurt
SyntaxGM:PlayerHurt( Player victim, Entity Attacker, Number Health Remaining, Number Damage Dealt )
DescriptionCalled when a player has taken damage.
ReturnsNil
Lua StateNewerServer.png
BBCode[b][url=wiki.garrysmod.com/?title=Gamemode.PlayerHurt]Gamemode.PlayerHurt [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Example

DescriptionPrints in the chat area when a player takes damage.
Used onNewerServer.png
Code
 
 /*--------------------------------------------------------- 
    Name: gamemode:PlayerHurt( ) 
    Desc: Called when a player is hurt. If the attacker was 
 		  a player then attacker will become a Player instead 
 		  of an Entity. 		  
 ---------------------------------------------------------*/ 
 function GM:PlayerHurt( player, attacker ) 
     player:ChatPrint( "You are being attacked by: " .. attacker:GetName() )
end 
 
OutputN/A


Additional Notes

See Also


Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox