dmginfo:victim problem

I have a problem with a script
dmginfo:victim doesn’t work
How to return the victim of attack?



function ENT:FireTurret(src, dir, dmginfo )
local owner = self:GetObjectOwner()
if ( dmginfo:victim == owner ) then return end

	if self:GetNextFire() <= CurTime() then
		local curammo = self:GetAmmo()
		if curammo > 0 then
			self:SetNextFire(CurTime() + 0.1)
			self:SetAmmo(curammo - 1)
			self:StartBulletKnockback()
            self:FireBullets({Num = 1, Src = src, Dir = dir, Spread = Vector(0.05, 0.05, 0), Tracer = 1, Force = 1, Damage = 12, Callback = BulletCallback})
			self:DoBulletKnockback(0.05)
			self:EndBulletKnockback()
		else
			self:SetNextFire(CurTime() + 2)
			self:EmitSound("npc/turret_floor/die.wav")
		end
	end
end


Your function has a victim argument, maybe you can just call


victim == owner

Changed. Does not work.
There is a way to return the recipient’s damage?

[editline]17th March 2016[/editline]

I done it



function ENT:FireTurret(src, dir, victim, dmginfo )
local owner = self:GetObjectOwner()
local target = self:GetTarget()

local function TurretTakeDMGone(victim, dmg)
if dmg:GetInflictor() == self and victim == owner then return true end
end

hook.Add("EntityTakeDamage", "TurretTakeDMGone", TurretTakeDMGone)

	if self:GetNextFire() <= CurTime() then
		local curammo = self:GetAmmo()
		if curammo > 0 then
			self:SetNextFire(CurTime() + 0.1)
			self:SetAmmo(curammo - 1)
			self:StartBulletKnockback()
            self:FireBullets({Num = 1, Src = src, Dir = dir, Spread = Vector(0.05, 0.05, 0), Tracer = 1, Force = 1, Damage = 12, Callback = BulletCallback})
			self:DoBulletKnockback(0.05)
			self:EndBulletKnockback()
		else
			self:SetNextFire(CurTime() + 2)
			self:EmitSound("npc/turret_floor/die.wav")
		end
	end
end