What I want to achieve
I want the weapon to continue playing a sound even after I clicked to fire again, the weapon to reload on pressing reload when it has an empty clip.
Code
local ShootSound = Sound(“Pew.mp3”) --Sound it makes when firing.
SWEP.Primary.TakeAmmo = 1 – How much ammo will be taken per shot.
SWEP.Primary.ClipSize = 7 – How much bullets are in the mag.
SWEP.Primary.Ammo = “Pistol” --The ammo type will it use.
SWEP.Primary.DefaultClip = 42 – How much bullets preloaded when spawned.
SWEP.Primary.NumberofShots = 1 – Number of bullets when shot.
SWEP.Primary.MaxAmmo = 35
SWEP.DrawAmmo = true
SWEP.FiresUnderwater = true
SWEP.CSMuzzleFlashes = true
function SWEP:PrimaryAttack()
if ( !self:CanPrimaryAttack() ) then return end
local bullet = {}
bullet.Num = self.Primary.NumberofShots
bullet.Src = self.Owner:GetShootPos()
bullet.Dir = self.Owner:GetAimVector()
bullet.Spread = Vector( self.Primary.Spread * 0.1 , self.Primary.Spread * 0.1, 0)
bullet.Tracer = 1
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(ShootSound)
self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) )
self:TakePrimaryAmmo(self.Primary.TakeAmmo)
self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
end
function SWEP:Reload()
self:EmitSound(Sound(self.ReloadSound))
self.Weapon:DefaultReload( ACT_VM_RELOAD );
end
What I’ve researched/found
For the ammo issue, I found out its because the SWEP.Primary.DefaultClip being 1, I’ve changed it up, but It still didn’t work.
For the audio issue, I tried adding in a sound table, a sound.Add function, but nothing works from what I’ve experimented.