• Killed by player instead of entity/world
    4 replies, posted
Few things of top of my head (turret, tripmines, etc) all register the death of a person for example npc_turret_floor So for example in console you'd have [QUOTE][01/12/14 02:29:55] Some guy [] was killed by npc_turret_floor.[/QUOTE] and damage logs [QUOTE]<something/world> has killed Some guy [innocent][/QUOTE] Is it possible to change this, so that the owner is awarded the kill? as for the turret, it creates the entity 'npc_turret_floor', in which ent:SetOwner() and ent:SetPhysicsAttacker() are both set as the person who deployed the turret. So technically this should be setting the deployer as the person who gets credited with the kill correct? but evidently it is not :P Any ideas?
[code]hook.Add("EntityTakeDamage", "lel", function(ent, dmginfo) local attacker = dmginfo:GetAttacker() if attacker:IsValid() then local owner = attacker:GetOwner() if owner:IsValid() then dmginfo:SetAttacker(owner) end end end)[/code]
Thanks, works perfectly for the turret however doesn't work for the tripmine Tripmine creates entity npc_tripmine, then when the person dies they die from env_explosion
When spawning the npc_tripmine, use ent:SetDamageOwner(ply)
Tried that Currently has mine:SetOwner(ply) mine:SetDamageOwner(ply) mine:SetPhysicsAttacker(ply) and tried the above code for using EntityTakeDamage hook.
Sorry, you need to Log In to post a reply to this thread.