Sorry for neglecting the topic, was away for a couple weeks.
[lua]
function SWEP:Reload()
local clip = self:Clip1();
local ammo = self:Ammo1();
if( clip >= self.Primary.ClipSize or ammo <= 0 ) then return end
if( CurTime() <= self.NextShot ) then return end
if( self.Reloading == 0 ) then -- init
self:PlayAnim( ACT_SHOTGUN_RELOAD_START );
self.Owner:SetAnimation( PLAYER_RELOAD );
self.Reloading = 1;
self.NextShot = CurTime() + 0.6;
timer.Simple( 0.6, function() self:Reload() end );
return;
elseif( self.Reloading == 1 ) then -- action
self.Reloading = 2;
self:EmitSound( table.Random( self.ReloadSounds ) );
self:SendWeaponAnim( ACT_VM_RELOAD );
--self:PlayAnim( ACT_VM_RELOAD, ACT_SHOTGUN_PUMP );
timer.Simple( 0.5, function() self:Reload() end );
self.NextShot = CurTime() + 0.5;
else -- add ammo
self:SetClip1( clip + 1 );
self.Owner:RemoveAmmo( 1, self.Primary.Ammo );
self.Reloading = 1;
if( self:Clip1() == 8 ) then
self.Reloading = 0;
self:Pump();
else
self:Reload();
end
end
end
[/lua]
SWEP:PlayAnim() (it works but flickers)
[lua]
function SWEP:PlayAnim( act, opt )
if( not opt ) then opt = ACT_VM_IDLE end
self:SendWeaponAnim( opt );
timer.Simple( 0.025, function() self:SendWeaponAnim( act ) end );
end
[/lua]
[editline]08:03PM[/editline]
SWEP:Pump() (in case of curiosity)
[lua]
function SWEP:Pump()
self:PlayAnim( ACT_SHOTGUN_PUMP );
self:PumpSound();
end
function SWEP:PumpSound()
if( SERVER ) then
self:EmitSound( Sound( "weapons/scock1.wav" ) );
end
end
[/lua]