0

GM:OnNpcKilled() don't work properly because killer of the NPC isn't a player, how it should be. Instead it is a bullet

here's my part of code that creating bullet for SWEP:

local Bullet = {}
        Bullet.Num = self.Primary.NumShots
        Bullet.Src = player:GetShootPos()
        Bullet.Dir = player:GetAimVector()
        Bullet.Spread = Vector(self.Primary.Spread, self.Primary.Spread, 0)
        Bullet.Tracer = 0
        Bullet.Damage = self.Primary.Damage
        Bullet.AmmoType = self.Primary.Ammo

part for giving player ammo when NPC is killed:

function GM:OnNPCKilled(npc, attacker, inflictor)
    inflictor:GiveAmmo(1, 13, true)
    print(inflictor:GetAmmoCount(13))
end

Basically I need to set killer to player instead of bullet, but I don't know how

amycodes
  • 902
  • 14

1 Answers1

0

I fixed it and realized that killer not a bullet, it's a SWEP. So i jus needed to change self:FireBullets() to player:FireBullets()