Swep Trouble

Warning: I dont to much post so if this dosnt look so good that is why

Ok, this is my first swep and i dont know much about coding but everytime i remove the secondary settings it turns into a secondary shotgun blast! can someone give me a code that does the same thing but dosnt have a secondary???
Code:

[lua]
if ( SERVER ) then

AddCSLuaFile( “shared.lua” )

SWEP.HoldType = “Pistol”

end

if ( CLIENT ) then
SWEP.Category = “Deagle Railgun”;
SWEP.PrintName = “Rail-deagle”
SWEP.Author = “Ultimatly Awes0me!”
SWEP.Contact = “”
SWEP.Purpose = “”
SWEP.Instructions = “Primary:Lightning”
SWEP.Slot = 1
SWEP.SlotPos = 1
SWEP.IconLetter = “f”

SWEP.ViewModelFlip = true

killicon.AddFont(“cse_deagle”,“CSKillIcons”,SWEP.I conLetter,Color(255,80,0,255))

end

SWEP.DrawCrosshair = true
SWEP.DrawAmmo = true

SWEP.Spawnable = false
SWEP.AdminSpawnable = true

SWEP.ViewModel = “models/weapons/v_pist_deagle.mdl”
SWEP.WorldModel = “models/weapons/w_pist_deagle.mdl”

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

SWEP.Primary.Recoil = 0
SWEP.Primary.Damage = 200
SWEP.Primary.NumShots = 0
SWEP.Primary.Cone = 0
SWEP.Primary.ClipSize = 7
SWEP.Primary.Delay = 0.06
SWEP.Primary.DefaultClip = 50
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = “pistol”

SWEP.Secondary.Recoil = 0.0
SWEP.Secondary.Damage = 9999
SWEP.Secondary.NumShots = 1
SWEP.Secondary.Cone = 0.0
SWEP.Secondary.ClipSize = 9999
SWEP.Secondary.Delay = 0.0
SWEP.Secondary.DefaultClip = 9998
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = “none”

function SWEP:PrimaryAttack()

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

self.Weapon:EmitSound(Sound(“Weapon_DEagle.Single” ))

self:ShootBullet( 0, 0, 0 )

self:TakePrimaryAmmo( 0 )

self.Owner:ViewPunch( Angle( 0, 0, 0 ) )
self.Weapon:SetNextPrimaryFire( CurTime() + 0.15 )

local trace = self.Owner:GetEyeTrace()
local effectdata = EffectData()
effectdata:SetOrigin( trace.HitPos )
effectdata:SetNormal( trace.HitNormal )
effectdata:SetEntity( trace.Entity )
effectdata:SetAttachment( trace.PhysicsBone )
util.Effect( “super_explosion”, effectdata )

local effectdata = EffectData()
effectdata:SetOrigin( trace.HitPos )
effectdata:SetStart( self.Owner:GetShootPos() )
effectdata:SetAttachment( 1 )
effectdata:SetEntity( self.Weapon )
util.Effect( “ToolTracer”, effectdata )
if (SERVER) then
local owner=self.Owner
if self.Owner.SENT then
owner=self.Owner.SENT.Entity
end

local explosion = ents.Create( “env_explosion” )
explosion:SetPos(trace.HitPos)
explosion:SetKeyValue( “iMagnitude” , “170” )
explosion:SetPhysicsAttacker(owner)
explosion:SetOwner(owner)
explosion:Spawn()
explosion:Fire(“explode”,"",0)
explosion:Fire(“kill”,"",0 )

end
end

function SWEP:SecondaryAttack()

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

self.Weapon:EmitSound(Sound(“none”))

self:ShootBullet( 0, 0, 0 )

self:TakePrimaryAmmo( 0 )

self.Owner:ViewPunch( Angle( 0, 0, 0 ) )
self.Weapon:SetNextPrimaryFire( CurTime() + 0.15 )

local trace = self.Owner:GetEyeTrace()
local effectdata = EffectData()
effectdata:SetOrigin( trace.HitPos )
effectdata:SetNormal( trace.HitNormal )
effectdata:SetEntity( trace.Entity )
effectdata:SetAttachment( trace.PhysicsBone )
util.Effect( “”, effectdata )

local effectdata = EffectData()
effectdata:SetOrigin( trace.HitPos )
effectdata:SetStart( self.Owner:GetShootPos() )
effectdata:SetAttachment( 1 )
effectdata:SetEntity( self.Weapon )
util.Effect( “”, effectdata )
if (SERVER) then
local owner=self.Owner
if self.Owner.SENT then
owner=self.Owner.SENT.Entity
end

local explosion = ents.Create( “env_explosion” )
explosion:SetPos(trace.HitPos)
explosion:SetKeyValue( “iMagnitude” , “5000” )
explosion:SetPhysicsAttacker(owner)
explosion:SetOwner(owner)
explosion:Spawn()
explosion:Fire(“explode”,"",0)
explosion:Fire(“kill”,"",0 )

end
end
[/lua]


(User was banned for this post ("Undescriptive thread title" - mahalis))

[lua]function SWEP:SecondaryAttack()
end[/lua]

If you put nothing, the game doesn’t know what to do with secondary, so it just shotgunblasts it.
When you put secondaryattack and leave everything blank, that’ll make the secondary do nothing

Thanks!

That is not true.

Every SWEP is derived from weapon_base, defined in the garrysmod content.gcf.
If you make a SWEP spawnable but leave out every function, it will act exactly like weapon_base. If you leave out primary attack, it’ll use weapon_base’s primary attack function.
Garry’s Mod runs this code from weapon_base if you don’t define it to override it:
[lua]
function SWEP:SecondaryAttack()

// Make sure we can shoot first
if ( !self:CanSecondaryAttack() ) then return end

// Play shoot sound
self.Weapon:EmitSound("Weapon_Shotgun.Single")

// Shoot 9 bullets, 150 damage, 0.75 aimcone
self:ShootBullet( 150, 9, 0.2 )

// Remove 1 bullet from our clip
self:TakeSecondaryAmmo( 1 )

// Punch the player's view
self.Owner:ViewPunch( Angle( -10, 0, 0 ) )

end
[/lua]
In fact, you cannot make a SWEP without a base. There are hundreds of lines of code defined in weapon_base, and the most you can do is override variables and functions to make your own SWEP act differently.