Need help fixing my weapon

2 days ago I came here asking for someone to help me add zoom to my weapon, no one really helped me much, some helped a bit tho.
Now I finally added zoom, but now it won’t shoot, ha ha ha ;-;
Please, help me fix the weapon.
GitHub code



if ( SERVER ) then

	AddCSLuaFile( "weapon_snp.lua" )
	AddCSLuaFile( "cl_zoom.lua" )
	SWEP.HoldType = "crossbow"
	
end

SWEP.PrintName   =  "Sniper"
SWEP.Author      =   "Alemismun & GhostFox"
SWEP.Purpose	 =	"Let the heads roll!"

SWEP.Category    = "Other"

SWEP.Base		= "weapon_cs_base"


SWEP.Spawnable   = true 
SWEP.AdminSpawnable =  true
SWEP.ViewModelFlip  = false

SWEP.ViewModelFOV	= 75

SWEP.Slot					= 3
SWEP.SlotPos				= 4

SWEP.ViewModel			= "models/weapons/cstrike/c_snip_scout.mdl"
SWEP.WorldModel			= "models/weapons/w_snip_scout.mdl"

SWEP.Primary.Recoil = 10
SWEP.Primary.Damage = 95
SWEP.Primary.NumShots = 1
SWEP.Primary.Spread = 0.001
SWEP.Primary.Cone = 0.005
SWEP.Primary.ClipSize = 2
SWEP.Primary.DefaultClip = 8
SWEP.Primary.Ammo = "shotgun"
SWEP.Primary.Automatic = false
SWEP.Primary.Delay = 3

SWEP.Secondary.Sound		= Sound( "weapons/sniper/sniper_zoomin.wav" )
SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic	= false
SWEP.Secondary.Ammo			= "none"

SWEP.data = {}
SWEP.firemode = "Single"
SWEP.data.Scope = true
ScopeLevel = 0

function SWEP.Initialize()
    util.PrecacheSound( "Weapon_AR2.NPC_Single" )
    end

----------PrimaryAttack---------
function SWEP:PrimaryAttack()

	if(ScopeLevel == 0) then
		self.Primary.Recoil = 10
		self.Primary.Cone = 0.015
		self.Primary.Delay	= 0.8
	else
		self.Primary.Recoil = 0
		self.Primary.Cone = 0.005
		self.Primary.Delay = 0.9
	end

	self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
	self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
	
	if ( !self:CanPrimaryAttack() ) then return end
	
	// Play shoot sound
	self.Weapon:EmitSound( self.Primary.Sound )

	// Shoot the bullet
	self:CSShootBullet( self.Primary.Damage, self.Primary.Recoil, self.Primary.NumShots, self.Primary.Cone )
	
	// Punch the player's view
	self.Owner:ViewPunch( Angle( math.Rand(-0.2,-0.1) * self.Primary.Recoil, math.Rand(-0.1,0.1) *self.Primary.Recoil, 0 ) )	
end
----------SecondaryAttack----------
function SWEP:SecondaryAttack()
 
	if(ScopeLevel == 0) then
   
        	if(SERVER) then
            		self.Owner:SetFOV( 30, 0 )
        	end 
       
        	ScopeLevel = 1
    
	else if(ScopeLevel == 1) then
		if(SERVER) then
			self.Owner:SetFOV( 10, 0 )
		end
		ScopeLevel = 2
	
	else
 
        	if(SERVER) then
			self.Owner:SetFOV( 0, 0 )
        	end  
       
        	ScopeLevel = 0
       
    	end
    	end
end
---------SecondaryAttackEnd----------
function SWEP:Holster()
	self.Owner:SetFOV( 0, 0 )
	ScopeLevel = 0
   
	return true
end 
function SWEP:Reload()
	self.Weapon:DefaultReload(ACT_VM_RELOAD)
	self.Weapon:EmitSound( self.Primary.ReloadSound )
	if(SERVER) then
	self.Owner:SetFOV( 0, 0 )
    end
    ScopeLevel = 0
	self.data.newclip = 1
	return true
end




include('weapon_snp.lua')

function SWEP:DrawHUD()

	if(ScopeLevel > 0) then
			local ScW, ScH, ScopeId
	
			ScW = surface.ScreenWidth()
			ScH = surface.ScreenHeight()
			
	
			ScopeId = surface.GetTextureID("weapons/scopes/scope")
			surface.SetTexture(ScopeId)
		
			QuadTable = {}
			
			QuadTable.texture 	= ScopeId
			QuadTable.color		= Color( 255, 255, 255, 255 )
			
			QuadTable.x = 0
			QuadTable.y = 0
			QuadTable.w = ScW
			QuadTable.h = ScH	
			draw.TexturedQuad( QuadTable )
	end
		
end


You have no bullets, or there’s an error, nothing else
Since it doesn’t shoot, most possibly it’s because in PrimaryAttack it’s being deflected by return

[lua]if ( !self:CanPrimaryAttack() ) then return end[/lua]

Change

[lua]self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )

if ( !self:CanPrimaryAttack() ) then return end[/lua]

to

[lua]
if ( !self:CanPrimaryAttack() ) then return end
self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
[/lua]

Because CanPrimaryAttack() contains this:

[lua]if self:GetNextPrimaryFire() > CurTime() then return false end[/lua]

So you’re essentially making this condition invalid before you even check it

Oh I see, that makes sense.

It still gaves me an error



SWEP (weapon_snp) is derived from non existant SWEP (weapon_cs_base) - Expect errors!
SWEP (cl_zoom) is derived from non existant SWEP (weapon_cs_base) - Expect errors!

[ERROR] gamemodes/idm/entities/weapons/weapon_snp.lua:73: attempt to call method 'CanPrimaryAttack' (a nil value)
  1. unknown - gamemodes/idm/entities/weapons/weapon_snp.lua:73


I suppose Ill look in the code for ‘CanPrimaryAttack’ and see what arround it could cause a problem.

Since it stated its a nil value, I suppose that its a simple 1 and 0 thing, so I did this



if ( !self:CanPrimaryAttack(1) ) then return end


I someohow expected that to work… welp im out of ideas…

Read the error, you dont have weapon_cs_base…

and uhhh, how do I fix this?
Im completely new to lua

get weapon_cs_base

From where, I found this, would this do?

That looks like the wrong one. Where did you get this weapon from?

The weapon or the GitHub link?, the GitHub link I just randomly found it on the internet…

The weapon.

I made it off a gun that I found in the workshop
I could not find another better thing to use as a template so I used this.
It also fitted perfect my gamemode because I wanted guns to have unlimited ammo.

Either the base you need is in the same GMA or a linked base addon.

There was no base, only the addon.txt and the shared.lua
that was all.

Can you link to the addon?

yeah, http://steamcommunity.com/sharedfiles/filedetails/?id=719463967

Can I recommend for you a better way for scoping?
[LUA]
function SWEP:TranslateFOV(old)
self.currentfov = self.currentfov or 80
if self.Weapon:GetNWBool( “Scoping” ) == true then
self.currentfov = math.Approach(self.currentfov, 15, 0.4)
else
self.currentfov = math.Approach(self.currentfov, old, 0.4)
end
return self.currentfov
end
[/LUA]

and how do I add it in the weapon, what do I replace?

No seriously, where can I get it?

I dont know, find it, you took that code and you are missing it