Gun keeps shooting.
Okay so, a gun I am working on has a single shot per clip, and instead of reloading when I shoot and it is empty, it will will just keep firing as long as I click and taking bullets out of the additional clips, and even when the clips hit 0 it will still fire.
It will only "reload" when I press the reload button.
May we see some code snippets? And are there any errors being spit out?
idk all what you want to see so... here.
[lua]SWEP.Primary.ClipSize = 1
SWEP.Primary.Delay = 0.01
SWEP.Primary.DefaultClip = 10
SWEP.Primary.Force = 0
SWEP.Primary.Damage = 0
SWEP.Primary.NumShots = 1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "pistol"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
-- Some self variables
SWEP.TazedTime = 5
SWEP.ReloadTime = 10
SWEP.ReloadTimer = CurTime()
if ( !self:CanPrimaryAttack() ) then return end
local eyeTrace = self.Owner:GetEyeTrace()
if !eyeTrace.Entity:IsPlayer() then
local dist = self.Owner:EyePos():Distance(eyeTrace.Entity:GetPos())
if dist > 200 then
self.Owner:PrintMessage(HUD_PRINTCENTER, "Too Far Away!")
if eyeTrace.Entity:IsPlayer() and dist < 201 then
self.ReloadTimer = CurTime() + self.ReloadTime
tazedPlayer = eyeTrace.Entity
oldModel = eyeTrace.Entity:GetMaterial()
self:TakePrimaryAmmo( 1 )
Just add a clip check. It never hurts to be overly thorough. I'm not even sure how in the hell CanPrimaryAttack works.
Yay that worked. TY
Also yeah I don't really get how CanPrimaryAttack checks if you can attack.
[QUOTE=NnyAskC;35284054]Yay that worked. TY
Also yeah I don't really get how CanPrimaryAttack checks if you can attack.[/QUOTE]
Better just to do your own checks :v: