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?
No errors.
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()
function SWEP:PrimaryAttack()
if ( !self:CanPrimaryAttack() ) then return end
local eyeTrace = self.Owner:GetEyeTrace()
if !eyeTrace.Entity:IsPlayer() then
return
end
local dist = self.Owner:EyePos():Distance(eyeTrace.Entity:GetPos())
if dist > 200 then
self.Owner:PrintMessage(HUD_PRINTCENTER, "Too Far Away!")
return
end
if eyeTrace.Entity:IsPlayer() and dist < 201 then
self.Weapon:EmitSound("Weapon_StunStick.Activate")
self.BaseClass.ShootEffects(self)
self.ReloadTimer = CurTime() + self.ReloadTime
tazedPlayer = eyeTrace.Entity
oldModel = eyeTrace.Entity:GetMaterial()
self:tasePlayer(eyeTrace.Entity)
self:TakePrimaryAmmo( 1 )
end
end
[/lua]
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:
Sorry, you need to Log In to post a reply to this thread.