MadCows Weapons Error


[ERROR] addons/madcow/lua/weapons/weapon_mad_base/shared.lua:696: Tried to use a NULL entity!

           1. __index - [C]:-1

            2. unknown - addons/madcow/lua/weapons/weapon_mad_base/shared.lua:696

This is the function:


if (not self.Owner:IsNPC() and self.Weapon:Clip1() < 1) then
        timer.Simple(self.Owner:GetViewModel():SequenceDuration(), function() 
            if self.Owner and self.Owner:Alive() and self.Weapon:GetOwner():GetActiveWeapon():GetClass() == WeaponModel then -- this is Line 696
                self.ActionDelay = CurTime()
                self:Reload() 
            end
        end)
    end


I know theres a problem because of the timers from gmod13. But how to fix this?

Stop using mad cows.

What weapon pack you using?

None at the moment. I don’t use “Swep” packs.

I create swords instead.

A quick fix. Just check everything before using it.



if (IsValid( self.Owner) and not self.Owner:IsNPC() and self.Weapon:Clip1() < 1) then
        timer.Simple(self.Owner:GetViewModel():SequenceDuration(), function() 
           
            if IsValid(self.Owner) and self.Owner:Alive() and IsValid( self.Weapon:GetOwner() ) and IsValid( self.Weapon:GetOwner():GetActiveWeapon()) and self.Weapon:GetOwner():GetActiveWeapon():GetClass() == WeaponModel then 
                self.ActionDelay = CurTime()
                self:Reload() 
            end
        end)
    end


Thanks! Worked :wink: