My server launched today and we’ve been getting some issues with the SWEPs that I cooked up for it. An error is spammed constantly at random intervals by random SWEPs on the server, even if they aren’t being held by any players. The odd thing is, you’d think if it returns an error for the code not to work, right…? Well, no, that’s not the case here, as this weapon base does exactly what I expect of it - the weapon’s bodygroups are all set to 0 when holstered and they’re set to whatever they’re designated to be set to when the weapon is active. This is what’s really confusing me.
This happens with basically any SWEP that uses bodygroups, which is most of the weapons on my server.
[ERROR] addons/nutscript 1.1/lua/weapons/nut_sks.lua:21: Tried to use a NULL entity! 1. SetBodygroup - [C]:-1 2. unknown - addons/nutscript 1.1/lua/weapons/nut_sks.lua:21
The code for the weapon that just so happened to be causing the error that time:
if (CLIENT) then SWEP.PrintName = "SKS" SWEP.Author = "Tazmily" SWEP.SlotPos = 3 SWEP.IconLetter = "i" SWEP.NameOfSWEP = "nut_SKS" --always make this the name of the folder the SWEP is in. killicon.AddFont( SWEP.NameOfSWEP, "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) ) end function SWEP:Deploy() self.Owner:GetViewModel():SetBodygroup(1, 0) self:SendWeaponAnim(ACT_VM_DRAW) self:SetBodygroup(1, 0) return true end function SWEP:Holster() self.Owner:GetViewModel():SetBodygroup(1, 0) self:SetBodygroup(1, 0) return true end function SWEP:Initialize() self:SetHoldType(self.HoldType) end SWEP.Category = "Nutscript 1.1" SWEP.Base = "rcs_base" SWEP.Spawnable = true SWEP.AdminSpawnable = true SWEP.ViewModel = "models/tnb/weapons/c_sks.mdl" SWEP.WorldModel = "models/tnb/weapons/w_sks.mdl" SWEP.Weight = 5 SWEP.AutoSwitchTo = false SWEP.AutoSwitchFrom = false SWEP.Primary.Sound = Sound( "weapons/m249/m249_fire.wav" ) SWEP.Primary.Recoil = 0.1 SWEP.Primary.Damage = 45 SWEP.Primary.NumShots = 1 SWEP.Primary.Cone = 0.001 SWEP.Primary.ClipSize = 10 SWEP.Primary.Delay = .20 SWEP.Primary.DefaultClip = 0 SWEP.Primary.MaxReserve = 90 SWEP.Primary.Automatic = false SWEP.Primary.Ammo = "smg1" SWEP.UseHands = true SWEP.ViewModelFlip = false SWEP.ViewModelFOV = 55 SWEP.Primary.MaxSpread = 0.000001 --the maximum amount the spread can go by, best left at 0.20 or lower SWEP.Primary.Handle = 0.2 --how many seconds you have to wait between each shot before the spread is at its best SWEP.Primary.SpreadIncrease = 0.21/15 --how much you add to the cone after each shot SWEP.MoveSpread = 6 --multiplier for spread when you are moving SWEP.JumpSpread = 8 --multiplier for spread when you are jumping SWEP.CrouchSpread = 0.5 --multiplier for spread when you are crouching SWEP.Secondary.ClipSize = -1 SWEP.Secondary.DefaultClip = -1 SWEP.Secondary.Automatic = true SWEP.Secondary.Ammo = "none" SWEP.Zoom = 0 --pretty self explanitory, don't change this unless if you want the gun to be fucked up //SWEP.ZoomOutDelay = 0.2 -- this is used for the delay between when you shoot and when it zooms out to pull the bolt //SWEP.ZoomInDelay = 1.5 --always set this 0.2 higher than SWEP.Primary.Delay SWEP.Zoom1 = 30 --Field of view for the first zoom SWEP.Zoom2 = 15 --field of view for the second zoom SWEP.Zoom0Cone = 0.1 --spread for when not zoomed SWEP.Zoom1Cone = 0.01 --spread for when zoomed once SWEP.Zoom2Cone = 0.01 --spread for when zoomed twice SWEP.Secondary.ClipSize = -1 SWEP.Secondary.DefaultClip = -1 SWEP.Secondary.Automatic = true SWEP.Secondary.Ammo = "none" SWEP.IronSightsPos = Vector( -6.3496, 0, 4.247 ) SWEP.IronSightsAng = Vector( 0.3449, 0.1386, 0 )
I’m using a very, very lightly modified RCS base. The only modifications I made were to make it iron sight upon hitting right click and to remove the iron sights’ cross hair. This does very little to the functionality of the weapon, as the SWEPs themselves still work just fine - it’s just really annoying for our players and in-server admins, and it makes reading rcon logs hard due to the spam. Any suggestions?