Garry's Mod Wiki

Revision Difference

GM:PlayerShouldTakeDamage#527342

<function name="PlayerShouldTakeDamage" parent="GM" type="hook"> <ishook>yes</ishook> <description>Returns true if the player should take damage from the given attacker.</description> <realm>Server</realm> <predicted>No</predicted> <args> <arg name="ply" type="Player">The player</arg> <arg name="attacker" type="Entity">The attacker</arg> </args> <rets> <ret name="" type="boolean">Allow damage</ret> </rets> </function> ⤶ <example>⤶ <description>Block damages between two players on the same team.</description>⤶ <code>⤶ hook.Add( "PlayerShouldTakeDamage", "AntiTeamkill", function( ply, attacker )⤶ return ply:Team() != attacker:Team() -- that will return false if attacker and ply is on the same team.⤶ end )⤶ </code>⤶ ⤶ </example>