I have my SWEP inheritance set up like this:
[code]basecombatweapon -> weapon_dodbase -> weapon_dodbasegun -> weapon_dodfullauto_punch -> weapon_thompson[/code]
In basecombatweapon, I have this as the Holster function:
[code]function SWEP:Holster( pSwitchingTo )
// cancel any reload in progress.
self.m_bInReload = false
// Send holster animation
self:SendWeaponAnim( ACT_VM_HOLSTER )
return true
end[/code]
This works fine when holstering that specific weapon -- [URL="https://facepunch.com/showthread.php?t=1483883"]although I have my own problems with the actual anim[/URL]. When I holster any weapon inheriting from it however, it gives a shared error that SendWeaponAnim is a nil value. Here's a child weapon calling the basecombatweapon function:
[code]function SWEP:Holster( pSwitchingTo )
if ( not CLIENT ) then
local pPlayer = self.Owner
if ( IsValid( pPlayer ) ) then
pPlayer:SetFOV( 0, 0 ) // reset the default FOV -- Fix second argument/should it immidiately reset?
if ( self.m_iAltFireHint ) then
pPlayer:StopHintTimer( self.m_iAltFireHint )
end
end
end
self.m_bInReload = false
--self:SetSmackTime( -1 )
return BaseClass:Holster( pSwitchingTo )
end[/code]
The code seems to work fine when I store the old holster in a variable then run it like that, however, it's a really hacky solution:
[code]local holster = BaseClass.Holster[/code]
The same thing occurs with Clip1 in the Reload method in weapon_dodbasegun:
[code]function SWEP:Reload()
if ( self.m_bInReload ) then return false end
local pPlayer = self.Owner
local iClip1 = self:Clip1()
local iResult = self:_DefaultReload( self:GetMaxClip1(), self:GetMaxClip2(), self:GetReloadActivity() )
if ( not iResult ) then
return false
end
return true
end[/code]
weapon_dodfullauto_punch and weapon_thompson will both error when reloading regardless of how much is in the clip, erroring again saying that Clip1 is a nil value.
Both errors are shared.
[editline]12th September 2015[/editline]
After doing some more research, it seems that SWEP.Weapon doesn't exist in the weapons for some reason. Also, not overriding the Holster function prevents the error.
Should be BaseClass.Holster( self, pSwitchingTo ).
Sorry, you need to Log In to post a reply to this thread.