GetActiveWeapon on npc_grenade_frag

I have a SWEP that throws frag grenades, “npc_grenade_frag” to be exact, and whenever it kills an NPC, an error always pops into console:


[ERROR] gamemodes/base/gamemode/npc.lua:27: attempt to call method 'GetActiveWeapon' (a nil value)
  1. unknown - gamemodes/base/gamemode/npc.lua:27

The game is trying to find my grenade’s active weapon, which is nonexistent for obvious reasons.
Yet, the base Grenade weapon doesn’t have this problem.
??

Are you actually playing the base game mode? It looks like it from the error.

Cannot confirm, maybe post your SWEP code?

Here are the relavant parts…


function SWEP:ThrowGrenade()
local frag = ents.Create("npc_grenade_frag")

if(!IsValid(frag)) then return end
frag:SetPos(self.Owner:EyePos() + ( self.Owner:GetAimVector() * 16 ) )
frag:SetAngles( self.Owner:EyeAngles() )
frag:SetOwner(self.Owner)

frag:Spawn()

local phys = frag:GetPhysicsObject()
	if ( !IsValid( phys ) ) then frag:Remove() return end
	
	
	
	local velocity = self.Owner:GetAimVector()
	velocity = velocity * 1000
	velocity = velocity + ( VectorRand() * 10 ) -- a random element
	phys:ApplyForceCenter( velocity )
	frag:Fire("SetTimer",2,0)
	frag:SetOwner(self.Owner)
	--timer.Simple(3.5,function() frag:Ignite() end)
	

end


function SWEP:SecondaryAttack()

self:SetHoldType("shotgun")
self.Weapon:SetNextSecondaryFire(CurTime() + 1)
		

	self:ThrowGrenade()
	self:EmitSound("Weapon_SMG1.Special2")
	
	
	
	

end

Tested your code, no errors in sandbox. Probably fixed in the next update.