1. Post #1
    NnyAskC's Avatar
    April 2006
    101 Posts
    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.

  2. Post #2
    Gold Member
    Saint Devil's Avatar
    January 2009
    227 Posts
    May we see some code snippets? And are there any errors being spit out?

  3. Post #3
    NnyAskC's Avatar
    April 2006
    101 Posts
    No errors.

    idk all what you want to see so... here.

    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
    

  4. Post #4
    Bel Irkalli's Avatar
    January 2012
    167 Posts
    Just add a clip check. It never hurts to be overly thorough. I'm not even sure how in the hell CanPrimaryAttack works.
    Reply With Quote Edit / Delete Reply Windows Vista United States Show Events Lua Helper Lua Helper x 1 (list)

  5. Post #5
    NnyAskC's Avatar
    April 2006
    101 Posts
    Yay that worked. TY

    Also yeah I don't really get how CanPrimaryAttack checks if you can attack.

  6. Post #6
    Bel Irkalli's Avatar
    January 2012
    167 Posts
    Yay that worked. TY

    Also yeah I don't really get how CanPrimaryAttack checks if you can attack.

    Better just to do your own checks