Entity.TakeDamageInfo

From GMod Wiki

Revision as of 16:36, 6 January 2011 by Cube334 (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax Entity:TakeDamageInfo( Damage DamageInfo )
Description:
Apply damage to the specified entity.
Returns: nil
In Object: Entity
Realm: NewerServer.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Entity.TakeDamageInfo]Entity.TakeDamageInfo [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionWill make all NPC's take 50 bullet damage, credited to the first player found.
Used onNewerServer.png
Code
local dmginfo = DamageInfo()
dmginfo:SetDamage( 50 ) --50 damage
dmginfo:SetDamageType( DMG_BULLET ) --Bullet damage
dmginfo:SetAttacker( player.GetAll()[1] ) --First player found gets credit
dmginfo:SetDamageForce( Vector( 0, 0, 1000 ) ) --Launch upwards
 
for _, v in pairs ( ents.FindByClass( "npc_*" ) ) do --For all NPC's...
    v:TakeDamageInfo( dmginfo ) --Take damage!
end
OutputN/A


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox