Garry's Mod Wiki


  boolean GM:EntityTakeDamage( Entity target, CTakeDamageInfo dmg )


Called when an entity takes damage. You can modify all parts of the damage info in this hook.

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


1 Entity target
The entity taking damage
2 CTakeDamageInfo dmg
Damage info


1 boolean
Return true to completely block the damage event


Explosion damage is reduced to players only.

hook.Add( "EntityTakeDamage", "EntityDamageExample", function( target, dmginfo ) if ( target:IsPlayer() and dmginfo:IsExplosionDamage() ) then dmginfo:ScaleDamage( 0.5 ) // Damage is now half of what you would normally take. end end )


Players in vehicles takes halved damage.

hook.Add( "EntityTakeDamage", "EntityDamageExample2", function( target, dmginfo ) if ( target:IsVehicle() ) then local ply = target:GetDriver() if ( IsValid(ply) && dmginfo:GetDamage() > 1 ) then dmginfo:SetDamage(dmginfo:GetDamage() / 2) ply:TakeDamageInfo(dmginfo) dmginfo:SetDamage(0) end end end )