Garry's Mod Wiki


  GM:PlayerDeath( Player victim, Entity inflictor, Entity attacker )


Called when a player is killed by Player:Kill or any other normal means.

This hook is not called if the player is killed by Player:KillSilent. See GM:PlayerSilentDeath for that.

See Player:LastHitGroup if you need to get the last hit hitgroup of the player.

Player:Alive will return true in this hook.


1 Player victim
The player who died
2 Entity inflictor
Item used to kill the victim
3 Entity attacker
Player or entity that killed the victim


If the player suicides (he is the killer and the victim (ply)), then it will print a message to console. If someone else kills him, it will print a different message to console.

hook.Add( "PlayerDeath", "GlobalDeathMessage", function( victim, inflictor, attacker ) if ( victim == attacker ) then PrintMessage( HUD_PRINTTALK, victim:Name() .. " committed suicide." ) else PrintMessage( HUD_PRINTTALK, victim:Name() .. " was killed by " .. attacker:Name() .. ".") end end )
Output: If suicide:

Player1 has committed suicide.


Player1 was killed by Player2.