SWEP Burst Fire Help

Ok so i’m making a g18c for my server and i can’t seem to get it to work.

Here’s my code:

local burst = 0


function SWEP:PrimaryAttack()
    if burst < 3 then
        local burst = burst + 1
        timer.Simple( 0.18, self.PrimaryAttack, self )
    else
        local burst = 0
    end
end


And within a larger bit of code:


SWEP.Base                = "weapon_cs_base"

SWEP.Spawnable            = false
SWEP.AdminSpawnable        = true

SWEP.ViewModel            = "models/weapons/v_G18_mac10.mdl"
SWEP.WorldModel            = "models/weapons/w_G18_mac10.mdl"

SWEP.Weight                = 5
SWEP.AutoSwitchTo        = false
SWEP.AutoSwitchFrom        = false

SWEP.Primary.Sound            = Sound( "weapons/g18/mac10-1.wav" )
SWEP.Primary.Recoil            = 0.9
SWEP.Primary.Damage            = 34
SWEP.Primary.NumShots        = 1
SWEP.Primary.Cone            = 0.05
SWEP.Primary.ClipSize        = 18
SWEP.Primary.Delay            = 0.6
SWEP.Primary.DefaultClip    = 18
SWEP.Primary.Automatic        = false
SWEP.Primary.Ammo            = "pistol"

SWEP.Secondary.ClipSize        = -1
SWEP.Secondary.DefaultClip    = -1
SWEP.Secondary.Automatic    = false
SWEP.Secondary.Ammo            = "none"

SWEP.IronSightsPos = Vector (2.2534, -5.324, 1.6325)
SWEP.IronSightsAng = Vector (0, 0, 0.2991)

local burst = 0

function SWEP:PrimaryAttack()
    if burst < 3 then
        local burst = burst + 1
        timer.Simple( 0.18, self.PrimaryAttack, self )
    else
        local burst = 0
    end
end

There are no errors returned when the game starts up, when i pull it out, spawn it, fire it, use it. HOWEVER nothing shoots. no ammo is taken. nothing ever happens besides ironsights.

That’s because you’re not firing anything. You have to shoot the bullet your self. Look at the PrimaryFire function on this page. http://wiki.garrysmod.com/?title=SWEP

^ That is what I was going to say but I wasn’t totally sure of myself :stuck_out_tongue: Thanks, that helped me aswell.