Garry's Mod Wiki

GM:PlayerShouldTakeDamage

  boolean GM:PlayerShouldTakeDamage( Player ply, Entity attacker )

Description

Returns true if the player should take damage from the given attacker.

Applying damage from this hook to the player taking damage will lead to infinite loop/crash.

Arguments

1 Player ply
The player
2 Entity attacker
The attacker

Returns

1 boolean
Allow damage

Example

Block damages between two players on the same team.

hook.Add( "PlayerShouldTakeDamage", "AntiTeamkill", function( ply, attacker ) if ply:Team() == attacker:Team() then return false -- that will block damage if attacker and ply is on the same team. end end )