Gamemode.EntityTakeDamage

From GMod Wiki

Jump to: navigation, search
Event Hook
Hook NameEntityTakeDamage
SyntaxGM:EntityTakeDamage( Entity Target, Entity Inflictor(usually a weapon), Entity Attacker, Number amount of damage done, Ctakedamageinfo Damage Info )
DescriptionCalled each time an entity takes damage.
ReturnsNil
Lua StateNewerServer.png
BBCode[b][url=wiki.garrysmod.com/?title=Gamemode.EntityTakeDamage]Gamemode.EntityTakeDamage [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionCreates a new hook called when players take damage.
Used onNewerServer.png
Code
function GM:EntityTakeDamage( ent, inflictor, attacker, amount )
 
	if ( ent:IsPlayer() ) then
		hook.Call("PlayerTakeDamage", self, ent, inflictor, attacker, amount)
	end
 
end
OutputN/A



DescriptionReduce fall damage
Used onNewerServer.png
Code
function GM:EntityTakeDamage( ent, inflictor, attacker, amount, dmginfo )
 
	if ent:IsPlayer() and dmginfo:IsFallDamage() then
 
		dmginfo:ScaleDamage( 0.5 )      // Damage is now half of what you would normally take.
 
	end
 
end
OutputN/A


See Also


Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox