Garry's Mod Wiki

GM:PostEntityTakeDamage

  GM:PostEntityTakeDamage( Entity ent, CTakeDamageInfo dmginfo, boolean wasDamageTaken )

Description

Called when an entity receives a damage event, after passing damage filters, etc.

See GM:EntityTakeDamage if you wish to prevent damage events, or otherwise alter them.

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

Arguments

1 Entity ent
The entity that took the damage.
2 CTakeDamageInfo dmginfo
Detailed information about the damage event.
3 boolean wasDamageTaken
Whether the entity actually took the damage. (For example, shooting a Strider will generate this event, but it won't take bullet damage).

Example

Displays some info about damage taken event when they occur.

hook.Add( "PostEntityTakeDamage", "PostEntityTakeDamagePrintOut", function( ent, dmgInfo, wasDamageTaken ) print( dmgInfo:GetDamage() ) print( ent, dmgInfo:GetAttacker(), dmgInfo:GetWeapon(), dmgInfo:GetInflictor() ) end )