Garry's Mod Wiki

NEXTBOT:OnKilled

NEXTBOT:OnKilled( CTakeDamageInfo info )

Description

Called when the bot gets killed.

Arguments

1 CTakeDamageInfo info
The damage info

Example

Example of NPC becoming a ragdoll after death and sending death notification to everybodys killfeed.

function ENT:OnKilled( dmginfo ) hook.Call( "OnNPCKilled", GAMEMODE, self, dmginfo:GetAttacker(), dmginfo:GetInflictor() ) self:BecomeRagdoll( dmginfo ) end

Example

Removes the body after 5 seconds, to prevent having lots of bodies laying around after a while.

function ENT:OnKilled( dmginfo ) hook.Call( "OnNPCKilled", GAMEMODE, self, dmginfo:GetAttacker(), dmginfo:GetInflictor() ) local body = ents.Create( "prop_ragdoll" ) body:SetPos( self:GetPos() ) body:SetModel( self:GetModel() ) body:Spawn() self:Remove() timer.Simple( 5, function() body:Remove() end ) end
Output: The body disappears after 5 seconds.

Page Links


Special Pages


Wikis

?

Render Time: 59ms

DB GetPage 36
Generate Html 3
SaveChanges (1) 12
Render Body 0
Render Sidebar 5