NPCs Don't Like My Gun

I’m trying to make an NPC-only swep.

I have two problems.

  1. No npc will hold the damn thing right. I looked around and found that the weapon’s hold type needs now to be called on both client and server, so I put this in the SWEP’s shared lua file:
    [lua]
    function SWEP:Initialize()

    if (SERVER) then
    self:SetWeaponHoldType(self.HoldType)
    self:SetNPCFireRate(self.Primary.Delay)
    end

    if (CLIENT) then
    self:SetWeaponHoldType(self.HoldType)
    end
    end
    [/lua]
    But it didn’t make a difference. Earlier in the file, I of course wrote SWEP.HoldType = “ar2” Can anyone help me?

  2. I want the weapon to NOT drop when the NPC dies (because I don’t want anyone to pick it up, as it’s NPC-only). I tried adding this to the SWEP’s shared lua file:
    [lua]
    function SWEP:Think()

    if (CLIENT) then return end

    if (not(self.Owner)) then
    self:Remove()
    end
    end
    [/lua]
    But it didn’t make a difference. Any ideas?

[lua]function SWEP:OnDrop()
self:Remove()
end[/lua]

And just move SetWeaponHoldType out of the if SERVER then block

Thanks. The weapons don’t drop now.
However, they still don’t hold them correctly.
At the top of the code I have SWEP.HoldType = “ar2”
and here’s the code that you said to change:
[lua]
function SWEP:Initialize()

if (SERVER) then
	self:SetNPCFireRate(self.Primary.Delay)
	self:SetNPCMaxBurst(3)
end

self.SetWeaponHoldType(self.HoldType)

end
[/lua]
Did I change it correctly?

Change:


self.SetWeaponHoldType(self.HoldType)

To:


self:SetWeaponHoldType(self.HoldType)

STILL doesn’t fix it.
This is is occurring with MadCow’s special weapons as well as with mine.

EDIT:

I figured it out: it’s completely fucking magical. I tried EVERYTHING but NO holdtypes will EVER set in ANY of the SWEPs I make.