My swep "base" is not working properly, help?

Hi there :dance:

I’m begginer to coding and i was like: Damm , it is really annoying keep making a whole SWEP:PrimaryAttack()
So i thinked with myself, why don’t do a little base to help me?
Well i actually did it but the swep don’t look to fire anyway so if someone can help me with that…

Ps:Sorry if there is any English mistake, not my linguage





AddCSLuaFile("base.test.lua")

sound = "Weapon_AR2.Single"


SWEP.PrintName = "TEST wep"
    
SWEP.Author = "Happy Face"
SWEP.Contact = "Your Email"
SWEP.Purpose = "lol dunno"
SWEP.Instructions = "FTW"

SWEP.Category = "Test Weps"

SWEP.Spawnable= true
SWEP.AdminSpawnable= true
SWEP.AdminOnly = false
SWEP.CSMuzzleFlashes	= true

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

SWEP.Slot			= 1
SWEP.SlotPos			= 2
SWEP.DrawAmmo			= false
SWEP.DrawCrosshair		= true

SWEP.ViewModelFOV = 56
SWEP.ViewModel = "models/weapons/v_pistol.mdl" 
SWEP.WorldModel = "models/weapons/w_pistol.mdl"
SWEP.Primary.ClipSize		= 45
SWEP.Primary.DefaultClip	= 999
SWEP.Primary.Automatic		= true
SWEP.Primary.Ammo		= "none"

function SWEP:PrimaryAttack()

hook.Call("base.fire()")

end



The “base.test.lua” thing:




include("init.lua")


function base.fire() 



	if (  !self:CanPrimaryAttack() ) then return end
	self.Weapon:EmitSound( sound )
	self:ShootBullet( 150, 1, 0.01 )
	self:TakePrimaryAmmo( 1 )
	self.Owner:ViewPunch( Angle( -1, 0, 0 ) )

end




There is no error inside Garrys Mod itself, then i don’t know what is happening.

Also if there is an Administrator here, could you please remove this:
Link to thread