TTT SWEP Instant Reload?

Hello, I noticed in this new SWEP I added to my server that it would reload (fully) in a second or so and it would stay in the reload position.
I was wondering if someone was willing to check out the code and give me some pointers on how I could fix it?



/*---------------------------------------------------------
        Reload does nothing
---------------------------------------------------------*/
 
/*---------------------------------------------------------
   Think does nothing
---------------------------------------------------------*/
function SWEP:Think()
 
        if self.Weapon:Clip1() > self.Primary.ClipSize then
                self.Weapon:SetClip1(self.Primary.ClipSize)
        end
 
        if self.Weapon:GetNetworkedBool( "reloading") == true then
				
                if self.Weapon:GetNetworkedInt( "reloadtimer") < CurTime() then
                        if self.unavailable then return end
 
                        if ( self.Weapon:Clip1() >= self.Primary.ClipSize || self.Owner:GetAmmoCount( self.Primary.Ammo ) <= 0 ) then
                                self.Weapon:SetNextPrimaryFire(CurTime() + 0.8)
                                self.Weapon:SetNextSecondaryFire(CurTime() + 0.8)
                                self.Weapon:SetNetworkedBool( "reloading", false)
                                self.Weapon:EmitSound( "weapons/m3/s3_pump.wav" )
                                self.Weapon:SendWeaponAnim(ACT_SHOTGUN_RELOAD_FINISH)
                        else
                       
                        self.Weapon:SetNetworkedInt( "reloadtimer", CurTime() + 0.45 )
                        self.Weapon:SendWeaponAnim( ACT_VM_RELOAD )
                        self.Owner:RemoveAmmo( 1, self.Primary.Ammo, false )
                        self.Weapon:SetClip1(  self.Weapon:Clip1() + 1 )
                        self.Weapon:SetNextPrimaryFire(CurTime() + 0.8)
                        self.Weapon:SetNextSecondaryFire(CurTime() + 0.8)
                        self.Weapon:EmitSound( "weapons/m3/s3_insertshell.wav" )
 
                                if ( self.Weapon:Clip1() >= self.Primary.ClipSize || self.Owner:GetAmmoCount( self.Primary.Ammo ) <= 0) then
                                        self.Weapon:SetNextPrimaryFire(CurTime() + 1.5)
                                        self.Weapon:SetNextSecondaryFire(CurTime() + 1.5)
                                       
                                else
                                        self.Weapon:SetNextPrimaryFire(CurTime() + 0.5)
                                        self.Weapon:SetNextSecondaryFire(CurTime() + 0.5)
                                       
                                end
                        end
                end
        end
end


Full SWEP: http://pastebin.com/GftvFQb9
Thanks!

Call the reload animation manually.

SendWeaponAnim or something simular


self:TakePrimaryAmmo(self.Primary.TakeAmmo) 

I use this instead of


  self.Owner:RemoveAmmo( 1, self.Primary.Ammo, false )

and I am pretty sure you done need this but I could be wrong


   self.Weapon:SetClip1(  self.Weapon:Clip1() + 1) 

I tried removing and replacing the line with what you said you used but so far the reload animation stays after reloaded and it is still instant. :confused:
Does it work fully on your server or have you not used it?


//General Settings \\ 
SWEP.PrintName 		= "Gold Pistol" 
 
SWEP.Author 		= "Crazyman"
SWEP.Instructions 	= "My Swep" 
SWEP.Contact 		= ""
SWEP.Purpose 		= "Have Fun" 
 
SWEP.AdminSpawnable = true // Is the SWEP spawnable for admins? 
SWEP.Spawnable 		= true // Can everybody spawn this SWEP? - If you want only admins to spawn it, keep this false and admin spawnable true. 
 

SWEP.ViewModel 		= "models/weapons/v_pist_geagle.mdl" // The viewModel = the model you see when you're holding the weapon.
SWEP.WorldModel 	= "models/weapons/w_pist_geagle.mdl" // The world model = the model you when it's down on the ground.

SWEP.AutoSwitchTo 	= false // When someone picks up the SWEP, should it automatically change to your SWEP? 
SWEP.AutoSwitchFrom = true // Should the weapon change to the a different SWEP if another SWEP is picked up?
 
SWEP.Slot 			= 1 // Which weapon slot you want your SWEP to be in? (1 2 3 4 5 6) 
SWEP.SlotPos = 1 // Which part of that slot do you want the SWEP to be in? (1 2 3 4 5 6) 
 
SWEP.HoldType = "Pistol" // How is the SWEP held? (Pistol SMG Grenade Melee) 
 
SWEP.FiresUnderwater = true // Does your SWEP fire under water?
 
SWEP.Weight = 5 // Set the weight of your SWEP. 
 
SWEP.DrawCrosshair = true // Do you want the SWEP to have a crosshair? 
 
SWEP.Category = "Biobastards" // Which weapon spawning category do you want your SWEP to be in?
 
SWEP.DrawAmmo = true // Does the ammo show up when you are using it? True / False 
 
SWEP.ReloadSound = "sound/Weapon_SMG1.Reload" // Reload sound, you can use the default ones, or you can use your own; Example; "sound/myswepreload.wav" 
 
SWEP.base = "weapon_cs_base" //What your weapon is based on.
//General settings\\
 
//PrimaryFire Settings\\ 
SWEP.Primary.Sound = Sound( "Weapon_Deagle.Single" )
SWEP.Primary.Damage = 50 // How much damage the SWEP will do.
SWEP.Primary.TakeAmmo = 1 // How much ammo does the SWEP use each time you shoot?
SWEP.Primary.ClipSize = 16 // The clip size.
SWEP.Primary.Ammo = "Pistol" // The ammo used by the SWEP. (pistol/smg1) 
SWEP.Primary.DefaultClip = 8 // How much ammo do you get when you first pick up the SWEP? 
SWEP.Primary.Spread = 0.1 // Do the bullets spread all over when firing? If you want it to shoot exactly where you are aiming, leave it at 0.1 
SWEP.Primary.NumberofShots = 1 // How many bullets the SWEP fires each time you shoot. 
SWEP.Primary.Automatic = false // Is the SWEP automatic?
SWEP.Primary.Recoil = 5 // How much recoil does the weapon have?
SWEP.Primary.Delay = 0.6 // How long must you wait before you can fire again?
SWEP.Primary.Force = 1000 // The force of the shot.
SWEP.Primary.Cone = 0.02
SWEP.Primary.ClipMax = 36
//PrimaryFire settings\\

SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
 
 
//SWEP:PrimaryFire\\ 
function SWEP:PrimaryAttack()
 
	if ( !self:CanPrimaryAttack() ) then return end
 
	local bullet = {} 
		bullet.Num = self.Primary.NumberofShots //The number of shots fired
		bullet.Src = self.Owner:GetShootPos() //Gets where the bullet comes from
		bullet.Dir = self.Owner:GetAimVector() //Gets where you're aiming
		bullet.Spread = Vector( self.Primary.Spread * 0.1 , self.Primary.Spread * 0.1, 0)
                //The above, sets how far the bullets spread from each other. 
		bullet.Tracer = 0 
		bullet.Force = self.Primary.Force 
		bullet.Damage = self.Primary.Damage 
		bullet.AmmoType = self.Primary.Ammo 
 
	local rnda = self.Primary.Recoil * -1 
	local rndb = self.Primary.Recoil * math.random(-1, 1) 
 
	self:ShootEffects()
 
	self.Owner:FireBullets( bullet ) 
	self:EmitSound(Sound(self.Primary.Sound)) 
	self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) ) 
	self:TakePrimaryAmmo(self.Primary.TakeAmmo) 
 
	self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
	self:SetNextSecondaryFire( CurTime() + self.Primary.Delay ) 
end 

local IRONSIGHT_TIME = 0.25

function SWEP:GetViewModelPosition( pos, ang )

	if ( !self.IronSightsPos ) then return pos, ang end

	local bIron = self.Weapon:GetNetworkedBool( "Ironsights" )
	
	if ( bIron != self.bLastIron ) then
	
		self.bLastIron = bIron 
		self.fIronTime = CurTime()
		
		if ( bIron ) then 
			self.SwayScale 	= 0.3
			self.BobScale 	= 0.1
		else 
			self.SwayScale 	= 1.0
			self.BobScale 	= 1.0
		end
	
	end
	
	local fIronTime = self.fIronTime or 0

	if ( !bIron && fIronTime < CurTime() - IRONSIGHT_TIME ) then 
		return pos, ang 
	end
	
	local Mul = 1.0
	
	if ( fIronTime > CurTime() - IRONSIGHT_TIME ) then
	
		Mul = math.Clamp( (CurTime() - fIronTime) / IRONSIGHT_TIME, 0, 1 )
		
		if (!bIron) then Mul = 1 - Mul end
	
	end

	local Offset	= self.IronSightsPos
	
	if ( self.IronSightsAng ) then
	
		ang = ang * 1
		ang:RotateAroundAxis( ang:Right(), 		self.IronSightsAng.x * Mul )
		ang:RotateAroundAxis( ang:Up(), 		self.IronSightsAng.y * Mul )
		ang:RotateAroundAxis( ang:Forward(), 	self.IronSightsAng.z * Mul )
	
	
	end
	
	local Right 	= ang:Right()
	local Up 		= ang:Up()
	local Forward 	= ang:Forward()
	
	

	pos = pos + Offset.x * Right * Mul
	pos = pos + Offset.y * Forward * Mul
	pos = pos + Offset.z * Up * Mul

	return pos, ang
	
end



function SWEP:SetIronsights( b )

	self.Weapon:SetNetworkedBool( "Ironsights", b )

end


SWEP.NextSecondaryAttack = 0

function SWEP:SecondaryAttack()

	if ( !self.IronSightsPos ) then return end
	if ( self.NextSecondaryAttack > CurTime() ) then return end
	
	bIronsights = !self.Weapon:GetNetworkedBool( "Ironsights", false )
	
	self:SetIronsights( bIronsights )
	
	self.NextSecondaryAttack = CurTime() + 0.3
	
end

function SWEP:OnRestore()

	self.NextSecondaryAttack = 0
	self:SetIronsights( false )
	
end

SWEP.Primary.Cone = 0.00
SWEP.IronSightsPos = Vector(3.75, -3.701, 1.75)
SWEP.IronSightsAng = Vector(0, 0, 0)


Well this is the code for a deagle I made maybe you can use the code. This is not a instant reload

[editline]24th September 2013[/editline]

Notice on my primary attack it takes the ammo away ammo every shot then gives a kick / sound but does not set the clip

Hmm i’ve taken a look at your code and applied some to this one but so far nothing has worked for me :confused:
Thanks for the help though…

Let me see your whole guns code so I can trial /error it

First off,
SWEP.base = “weapon_cs_base” //What your weapon is based on.

That’s supposed to be
SWEP.Base = “weapon_tttbase” //What your weapon is based on.

Second, your custom model might suck.
It might have shitty animations. Reload speeds are based on animation lengths. Try changing to a better model.

This SWEP does not even use that base.
And it very well could be the models although I have asked a friend that has fixed it in the past and he said something about setting a reload timer.

I have included the full code at the bottom: http://pastebin.com/GftvFQb9

I’ve had the same problem before, I’ll send you what I did when I get on my laptop

[lua] function SWEP:Reload()
self.Weapon:SendWeaponAnim( ACT_VM_RELOAD )
end
[/lua]