How to make SWEP actually shoot? (Sorry I'm new)

I’m trying to learn how to make sweps, and i’m trying to make a deagle from counter strike, here’s the code:


SWEP.PrintName			= "Deagle"
SWEP.Author				= "( Blazertron )"
SWEP.Category			= "CS: S Ports"

SWEP.Spawnable			= true

SWEP.Primary.ClipSize			= 30
SWEP.Primary.DefaultClip		= 9999
SWEP.Primary.Ammo 				= "ar2"
SWEP.Primary.Damage				= 100

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

SWEP.ViewModel					= "models/weapons/v_pist_deagle.mdl"
SWEP.WorldModel					= "models/weapons/w_pist_deagle.mdl"

SWEP.ViewModelFlip					= true

local ShootSound = Sound("weapons/deagle-1.wav")

function SWEP:PrimaryAttack()

		self.Weapon:SetNextPrimaryFire(CurTime() + 0.25 )
		self.Weapon:EmitSound(ShootSound)
		self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
end


If i take the function away it shoots, but then I can’t control the sound or the ‘setnextprimaryfire’ It shoots but doesn’t do damge to anything. Also it doesn’t use the bullets either, the ammo count stays the same

Everything you need to know is here

Every time you create a weapon, it starts off with everything in there. So by modifying SWEP:PrimaryAttack() , you are overwriting the PrimaryAttack function in the base. Check out what it’s doing that you’re not, should give you a good start :slight_smile:

Thanks, I’ve been trying to use the chair launcher from garrysmod.com to find commands, but that just hasn’t been working