Garry's Mod Wiki

player_hurt

Description

Called when the player takes damage.

This is called after GM:EntityTakeDamage so you could just use that hook serverside.

Parameters

number health
The new health after being damaged.
number priority
[Server-only] Event priority number used by HLTV.
number userid
The UserID of the victim.
number attacker
The UserID of the attacker.

Examples

Example

This is a basic template with the purpose of including all arguments / table variables to make it easily known which values can be accessed.

gameevent.Listen( "player_hurt" ) hook.Add( "player_hurt", "player_hurt_example", function( data ) local health = data.health // Remaining health after injury local priority = SERVER and data.Priority or 5 // Priority ?? local id = data.userid // Same as Player:UserID() local attackerid = data.attacker // Same as Player:UserID() but it's the attacker id. // Called when the player is injured or dies. end )