Need someone to fix up my randomized swep

Hello everyone, I need someone to clear the client/server connections in this swep up for me, I’m currently kind of busy. Here’s the code:



if (SERVER) then

    AddCSLuaFile( "shared.lua" )
    SWEP.Weight                = 5
    SWEP.AutoSwitchTo        = false
    SWEP.AutoSwitchFrom        = false

end

if ( CLIENT ) then

    SWEP.DrawAmmo            = true
    SWEP.DrawCrosshair        = false
    SWEP.ViewModelFOV        = 82
    SWEP.ViewModelFlip        = true
    SWEP.CSMuzzleFlashes    = true
    
    -- This is the font that's used to draw the death icons
    surface.CreateFont( "csd", ScreenScale( 30 ), 500, true, true, "CSKillIcons" )
    surface.CreateFont( "csd", ScreenScale( 60 ), 500, true, true, "CSSelectIcons" )

end

SWEP.Author            = "Counter-Strike"
SWEP.Contact        = ""
SWEP.Purpose        = ""
SWEP.Instructions    = ""

-- Note: This is how it should have worked. The base weapon would set the category
-- then all of the children would have inherited that.
-- But a lot of SWEPS have based themselves on this base (probably not on purpose)
-- So the category name is now defined in all of the child SWEPS.
--SWEP.Category            = "Counter-Strike"

SWEP.Spawnable            = true
SWEP.AdminSpawnable        = true




function SWEP:Deploy()

local sweptypes = {"shotgun", "smg"}

local shotgun_sound = {"weapons/shotgun/shotgun_fire6.wav", "weapons/shotgun/shotgun_fire7.wav", "weapons/shotgun/shotgun_dbl_fire.wav", "weapons/m3/m3-1.wav", "weapons/xm1014/xm1014-1.wav"}
local smg_sound = {"weapons/smg1/smg1_fire1.wav", "weapons/p90/p90-1.wav", "weapons/mp5navy/mp5-1.wav", "weapons/mac10/mac10-1.wav"}
local shotgun_damage = { 12, 13, 9, 8 }
local smg_damage = { 15, 12, 8, 10 }
local shotgun_recoil = { 1.4, 1.2, 0.4, 0.9}
local smg_recoil = {0.1, 0.07, 0.12, 0.16}
local shotgun_shots = {math.random(3,14), 16, 8, 12, 10 }
local smg_shots = {1, 1, 2}
local shotgun_delay = {0.45, 0.75, 0.3, 0.6}
local smg_delay = {0.14, 0.12, 0.2, 0.17}
local shotgun_cone = {0.08, 0.11, 0.14, 0.03}
local smg_cone = {0.019, 0.012, 0.014, 0.005, 0.025}
local shotgun_holdtypes = {"shotgun"}
local smg_holdtypes = {"smg"}
local shotgun_models = {"shotgun.mdl","shot_m3super90.mdl", "shot_xm1014.mdl"}
local smg_models = {"smg1.mdl", "smg_mac10.mdl", "smg_mp5.mdl", "smg_p90.mdl", "smg_ump45.mdl"}

self.Type = table.Random(sweptypes)

if self.Type == "shotgun" then

self.Primary.Sound            = Sound(table.Random(shotgun_sound) )
self.Primary.Recoil            = table.Random(shotgun_recoil)
self.Primary.Damage            = table.Random(shotgun_damage)*1.5
self.Primary.NumShots        = table.Random(shotgun_shots)
self.Primary.Cone            = table.Random(shotgun_cone)
self.Primary.Delay            = table.Random(shotgun_delay)
self.HoldType = table.Random(shotgun_holdtypes)
self.Primary.Automatic        = false
local model = table.Random(shotgun_models)
self.ViewModel = "models/weapons/v_"..model
self.WorldModel = "models/weapons/w_"..model
else
self.Primary.Sound            = Sound(table.Random(smg_sound) )
self.Primary.Recoil            = table.Random(smg_recoil)
self.Primary.Damage            = table.Random(smg_damage)*1.5
self.Primary.NumShots        = table.Random(smg_shots)
self.Primary.Cone            = table.Random(smg_cone)
self.Primary.Delay            = table.Random(smg_delay)
self.HoldType = table.Random(smg_holdtypes)
self.Primary.Automatic        = true
local model = table.Random(smg_models)
self.ViewModel = "models/weapons/v_"..model
self.WorldModel = "models/weapons/w_"..model
end

self.Primary.ClipSize        = -1
self.Primary.DefaultClip    = -1
self.Primary.Ammo            = "none"

self.Secondary.ClipSize        = -1
self.Secondary.DefaultClip    = -1
self.Secondary.Automatic    = false
self.Secondary.Ammo            = "none"

self:SetWeaponHoldType( self.HoldType )

end

/*---------------------------------------------------------
---------------------------------------------------------*/
function SWEP:Initialize()

    if ( SERVER ) then
        self:SetNPCMinBurst( 30 )
        self:SetNPCMaxBurst( 30 )
        self:SetNPCFireRate( 0.01 )
    end

local smg_sound = {"weapons/smg1/smg1_fire1.wav", "weapons/p90/p90-1.wav", "weapons/mp5navy/mp5-1.wav", "weapons/mac10/mac10-1.wav"}
local smg_damage = { 15, 12, 8, 10 }
local smg_recoil = {0.1, 0.07, 0.12, 0.16}
local smg_shots = {1, 1, 2}
local smg_delay = {0.14, 0.12, 0.2, 0.17}
local smg_cone = {0.019, 0.012, 0.014, 0.005, 0.025}
local smg_holdtypes = {"smg"}
local smg_models = {"smg1.mdl", "smg_mac10.mdl", "smg_mp5.mdl", "smg_p90.mdl", "smg_ump45.mdl"}

self.Primary.Sound            = Sound(table.Random(smg_sound) )
self.Primary.Recoil            = table.Random(smg_recoil)
self.Primary.Damage            = table.Random(smg_damage)*1.5
self.Primary.NumShots        = table.Random(smg_shots)
self.Primary.Cone            = table.Random(smg_cone)
self.Primary.Delay            = table.Random(smg_delay)
self.HoldType = table.Random(smg_holdtypes)
self.Primary.Automatic        = true
local model = table.Random(smg_models)
self.ViewModel = "models/weapons/v_"..model
self.WorldModel = "models/weapons/v_"..model

self.Primary.ClipSize        = -1
self.Primary.DefaultClip    = -1
self.Primary.Ammo            = "none"

self.Secondary.ClipSize        = -1
self.Secondary.DefaultClip    = -1
self.Secondary.Automatic    = false
self.Secondary.Ammo            = "none"

self:SetWeaponHoldType( self.HoldType )

    
end


/*---------------------------------------------------------
    Reload does nothing
---------------------------------------------------------*/
function SWEP:Reload()
    self.Weapon:DefaultReload( ACT_VM_RELOAD );
end


/*---------------------------------------------------------
   Think does nothing
---------------------------------------------------------*/
function SWEP:Think()    
end


/*---------------------------------------------------------
    PrimaryAttack
---------------------------------------------------------*/
function SWEP:PrimaryAttack()

    self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
    self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
    
    
    -- Play shoot sound
    self.Weapon:EmitSound( self.Primary.Sound )
    print(self.Primary.Sound)
    
    
    -- Shoot the bullet
    self:CSShootBullet( self.Primary.Damage, self.Primary.Recoil, self.Primary.NumShots, self.Primary.Cone )
    
    -- Remove 1 bullet from our clip
    
    if ( self.Owner:IsNPC() ) then return end
    
    -- 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 ) )
    
    -- In singleplayer this function doesn't get called on the client, so we use a networked float
    -- to send the last shoot time. In multiplayer this is predicted clientside so we don't need to 
    -- send the float.
    if ( (SinglePlayer() && SERVER) || CLIENT ) then
        self.Weapon:SetNetworkedFloat( "LastShootTime", CurTime() )
    end
    
end

/*---------------------------------------------------------
   Name: SWEP:PrimaryAttack( )
   Desc: +attack1 has been pressed
---------------------------------------------------------*/
function SWEP:CSShootBullet( dmg, recoil, numbul, cone )

    numbul     = numbul     or 1
    cone     = cone         or 0.01

    local bullet = {}
    bullet.Num         = numbul
    bullet.Src         = self.Owner:GetShootPos()            -- Source
    bullet.Dir         = self.Owner:GetAimVector()            -- Dir of bullet
    bullet.Spread     = Vector( cone, cone, 0 )            -- Aim Cone
    bullet.Tracer    = 4                                    -- Show a tracer on every x bullets 
    bullet.Force    = 5                                    -- Amount of force to give to phys objects
    bullet.Damage    = dmg

    
    
    self.Owner:FireBullets( bullet )
    self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )         -- View model animation
    self.Owner:MuzzleFlash()                                -- Crappy muzzle light
    self.Owner:SetAnimation( PLAYER_ATTACK1 )                -- 3rd Person Animation
    
    if ( self.Owner:IsNPC() ) then return end
    
    -- CUSTOM RECOIL !
    if ( (SinglePlayer() && SERVER) || ( !SinglePlayer() && CLIENT && IsFirstTimePredicted() ) ) then
    
        local eyeang = self.Owner:EyeAngles()
        eyeang.pitch = eyeang.pitch - recoil
        self.Owner:SetEyeAngles( eyeang )
    
    end

end


/*---------------------------------------------------------
    Checks the objects before any action is taken
    This is to make sure that the entities haven't been removed
---------------------------------------------------------*/
function SWEP:DrawWeaponSelection( x, y, wide, tall, alpha )
    
end

local IRONSIGHT_TIME = 0.25

/*---------------------------------------------------------
   Name: GetViewModelPosition
   Desc: Allows you to re-position the view model
---------------------------------------------------------*/
function SWEP:GetViewModelPosition( pos, ang )

    if ( !self.IronSightsPos ) then return pos, ang end

    local bIron = self.Weapon:GetNetworkedBool( "Ironsights" )
    
    if ( bIron != self.bLastIron ) then
    
        self.bLastIron = bIron 
        self.fIronTime = CurTime()
        
        if ( bIron ) then 
            self.SwayScale     = 0.3
            self.BobScale     = 0.1
        else 
            self.SwayScale     = 1.0
            self.BobScale     = 1.0
        end
    
    end
    
    local fIronTime = self.fIronTime or 0

    if ( !bIron && fIronTime < CurTime() - IRONSIGHT_TIME ) then 
        return pos, ang 
    end
    
    local Mul = 1.0
    
    if ( fIronTime > CurTime() - IRONSIGHT_TIME ) then
    
        Mul = math.Clamp( (CurTime() - fIronTime) / IRONSIGHT_TIME, 0, 1 )
        
        if (!bIron) then Mul = 1 - Mul end
    
    end

    local Offset    = self.IronSightsPos
    
    if ( self.IronSightsAng ) then
    
        ang = ang * 1
        ang:RotateAroundAxis( ang:Right(),         self.IronSightsAng.x * Mul )
        ang:RotateAroundAxis( ang:Up(),         self.IronSightsAng.y * Mul )
        ang:RotateAroundAxis( ang:Forward(),     self.IronSightsAng.z * Mul )
    
    
    end
    
    local Right     = ang:Right()
    local Up         = ang:Up()
    local Forward     = ang:Forward()
    
    

    pos = pos + Offset.x * Right * Mul
    pos = pos + Offset.y * Forward * Mul
    pos = pos + Offset.z * Up * Mul

    return pos, ang
    
end


/*---------------------------------------------------------
    SetIronsights
---------------------------------------------------------*/
function SWEP:SetIronsights( b )

    self.Weapon:SetNetworkedBool( "Ironsights", b )

end


SWEP.NextSecondaryAttack = 0
/*---------------------------------------------------------
    SecondaryAttack
---------------------------------------------------------*/
function SWEP:SecondaryAttack()

    if ( !self.IronSightsPos ) then return end
    if ( self.NextSecondaryAttack > CurTime() ) then return end
    
    bIronsights = !self.Weapon:GetNetworkedBool( "Ironsights", false )
    
    self:SetIronsights( bIronsights )
    
    self.NextSecondaryAttack = CurTime() + 0.3
    
end

/*---------------------------------------------------------
    DrawHUD
    
    Just a rough mock up showing how to draw your own crosshair.
    
---------------------------------------------------------*/
function SWEP:DrawHUD()

    -- No crosshair when ironsights is on
    if ( self.Weapon:GetNetworkedBool( "Ironsights" ) ) then return end

    local x, y

    -- If we're drawing the local player, draw the crosshair where they're aiming,
    -- instead of in the center of the screen.
    if ( self.Owner == LocalPlayer() && self.Owner:ShouldDrawLocalPlayer() ) then

        local tr = util.GetPlayerTrace( self.Owner )
        tr.mask = ( CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_GRATE|CONTENTS_AUX )
        local trace = util.TraceLine( tr )
        
        local coords = trace.HitPos:ToScreen()
        x, y = coords.x, coords.y

    else
        x, y = ScrW() / 2.0, ScrH() / 2.0
    end
    
    local scale = 10 * self.Primary.Cone
    
    -- Scale the size of the crosshair according to how long ago we fired our weapon
    local LastShootTime = self.Weapon:GetNetworkedFloat( "LastShootTime", 0 )
    scale = scale * (2 - math.Clamp( (CurTime() - LastShootTime) * 5, 0.0, 1.0 ))
    
    surface.SetDrawColor( 0, 255, 0, 255 )
    
    -- Draw an awesome crosshair
    local gap = 40 * scale
    local length = gap + 20 * scale
    surface.DrawLine( x - length, y, x - gap, y )
    surface.DrawLine( x + length, y, x + gap, y )
    surface.DrawLine( x, y - length, x, y - gap )
    surface.DrawLine( x, y + length, x, y + gap )

end

/*---------------------------------------------------------
    onRestore
    Loaded a saved game (or changelevel)
---------------------------------------------------------*/
function SWEP:OnRestore()

    self.NextSecondaryAttack = 0
    self:SetIronsights( false )
    
end


There’s currently no real errors except client/server stuff such as swep types being different on server and client.

It’s currently a mess, if you can fix it up I’d be grateful.