SWEP isn't showing up in list

I started making these simple sweps, and sents, but they won’t show up in the lists. My SWEP’s code is like this:

cl_init.lua


include ("shared.lua")

SWEP.PrintName "Exploding M-4";
SWEP.Slot = 3;
SWEP.SlotPos = 1;
SWEP.DrawAmmo = true;
SWEP.Crosshair = true;


init.lua


AddCSLuaFile ("cl_init.lua");
AddCSLuaFile ("shared.lua");

include ("shared.lua");

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


shared.lua


SWEP.Author = "Frechetta93"
SWEP.Contact = "None"
SWEP.Purpose = "Blow crap up"
SWEP.Instructions = "Primary to fire an exploding bullet!"
SWEP.Category = "Rifles"

SWEP.Spawnable = true;
SWEP.AdminSpawnable = true;

SWEP.ViewModel = "models/weapons/W_RIF_M4A2.mdl";
SWEP.WorldModel = "models/weapons/W_RIF_M4A2.mdl";

SWEP.Primary.ClipSize = 32;
SWEP.Primary.DefaultClip = 64;
SWEP.Primary.Automatic = true;
SWEP.Primary.Ammo = "smg1";

SWEP.Sound = Sound ("weapon_ar2.Single")
SWEP.Damage = 100
SWEP.Spread = 0
SWEP.NumBul = 1
SWEP.Delay = 0.3
SWEP.Force = 5

function SWEP.Deploy()
    return true
end

function SWEP.Holster()
    return true
end

function SWEP.Think()
end


function SWEP.PrimaryAttack()

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

    local bullet = {}
    bullet.Num        = self.NumBul
    bullet.Src        = self.Owner.GetShootPos()
    bullet.Dir        = self.Owner.GetAimVector()
    bullet.Spread    = Vector ( self.Spread, self.Spread, 0 )
    bullet.Trace    = 0
    bullet.Force    = self.Force
    bullet.Damage    = self.Damage
    bullet.AmmoType = self.Primary.Ammo

    local explode = ents.Create( "env_explosion" )
    explode.SetPos( bullet.HitPos )
    explode.SetOwner( self.Owner )
    explode.Spawn()
    explode.SetKeyValue( "iMagnitute", "220" )
    explode.Fire( "Explode", 0, 0 )
    explode.EmitSound( "weapon_AWP.Single", 400, 400 )

    self.Owner:FireBullets( bullet )

    self.Weapon:EmitSound ( self.Sound )

    self.BaseClass.ShootEffects (self);

    self:TakePrimaryAmmo(1)
end

function SWEP:Reload()
    self.Weapon:DefaultReload( ACT_VM_RELOAD )
end


These are located in addons>Exploding M4>lua>weapons>exploding m4
and this is my info.txt:


"AddonInfo"
{
    "name"            "Exploding M4"
    "version"        "1.0"
    "up_date"        "2009"
    "author_name"        "Frechetta93"
    "author_email"        ""
    "info"            "Weapon"
    "overdirve"        "1"
}


This isn’t showing up in the weapons list, what am I doing wrong?

You spelt override wrong in the info.txt for starters…

One thing I see wrong in a lot of places is that you’re going entity.Function rather than entity:Function. Such as SWEP:Deploy, SWEP:PrimaryFire etc, explode:SetPos, explode:Fire etc in your primary fire function, and a few self.Owner bits. Basically you’ve often got a dot before the name of the function where you need a colon. I’m not sure if that’s what’s critically wrong with it.

I’m pretty sure you need SWEP.Spawnable = true and SWEP.AdminSpawnable = true in your init.lua as well.

Are cl_init.lua and init.lua needed? Because I checked out another SWEP that IO have downloaded and it doesn’t have either and it works fine.

I deleted cl_init.lua and init.lua to model after that SWEP, and I reorganized and added some stuff in shared.lua to resemble this: http://wiki.garrysmod.com/?title=SWEP

So here is my updated product, but it still doesn’t show up in the Weapons list.



if (SERVER) then
    AddCSLuaFile("shared.lua")
    SWEP.HoldType = "ar2"

end

//General Settings \\
SWEP.PrintName         = "Exploding M-4"

SWEP.Author         = "Frechetta93"
SWEP.Instructions     = "Primary to fire an exploding bullet!"
SWEP.Contact        = "Steam: sccrrulz122"
SWEP.Purpose         = "Blow crap up"

SWEP.Spawnable         = true
SWEP.AdminSpawnable     = true

SWEP.ViewModelFOV    = 60
SWEP.ViewModel         = "models/weapons/v_rif_m4a1.mdl"
SWEP.WorldModel     = "models/weapons/w_rif_m4a1.mdl"

SWEP.AutoSwitchTo     = false
SWEP.AutoSwitchFrom     = false

SWEP.Slot         = 2
SWEP.SlotPos         = 1

SWEP.HoldType         = "ar2"

SWEP.FiresUnderwater    = true

SWEP.Weight        = 5

SWEP.DrawCrosshair     = true

SWEP.Category         = "My Weapons"

SWEP.DrawAmmo         = true

SWEP.base        = "weapon_base"
//General Settings\\


//PrimaryFire Settings\\
SWEP.Primary.Sound     = Sound ("weapon_ar2.Single")
SWEP.Primary.Damage    = 25
SWEP.Primary.TakeAmmo    = 1
SWEP.Primary.ClipSize     = 32
SWEP.Primary.Ammo     = "smg1"
SWEP.Primary.DefaultClip     = 64
SWEP.Primary.Spread     = 0.1
SWEP.Primary.NumberofShots    = 1
SWEP.Primary.Automatic     = true
SWEP.Primary.Recoil    = 2
SWEP.Primary.Delay    = 0.1
SWEP.Primary.Force    = 1000
//PrimaryFire Settings\\


//SWEP:Initialize\\
function SWEP:Initialize()
    util.PrecacheSound(self.Primary.Sound)
    self:SetWeaponHoldType( self.HoldType )
end
//SWEP:Initialize\\


//SWEP:PrimaryFire\\
function SWEP:PrimaryAttack()
    if ( !self:CanPrimaryAttack() ) then return end

    local bullet = {}
        bullet.Num    = self.Primary.NumberofShots
        bullet.Src    = self.Owner.GetShootPos()
        bullet.Dir    = self.Owner.GetAimVector()
        bullet.Spread    = Vector ( self.Primary.Spread, self.Primary.Spread, 0 )
        bullet.Tracer    = 0
        bullet.Force    = self.Primary.Force
        bullet.Damage    = self.Primary.Damage
        bullet.AmmoType = self.Primary.Ammo

    local rnda    = self.Primary.Recoil * -1
    local rndb    = self.Primary.Recoil * math.random(-1, 1)

    self:ShootEffects()
    
    self.Owner:FireBullets( bullet )
    self:EmitSound(Sound(self.Primary.Sound))
    self.Owner:ViewPunch( Angle( rnda, rndb, rnda ) )
    self:TakePrimaryAmmo(self.Primary.TakeAmmo)

    self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )

    local explode     = ents.Create("env_explosion")
        explode:SetPos( bullet.HitPos )
        explode:SetOwner( self.Owner )
        explode:Spawn()
        explode:SetKeyValue("iMagnitude", "220")
        explode:Fire( "Explode", 0, 0 )
        explode:EmitSound( "weapon_AWP.Single", 400, 400 )    
end
//SWEP:PrimaryFire\\


Init and cl_init are optional. I’ve just noticed - your SWEP’s folder, the one containing the scripts, has a space in its name. I’m pretty sure that’s not allowed.

Also, in your Initialize you’re calling SetWeaponHoldType shared (which is right) but you’re only setting SWEP.HoldType on the server. On the client you’ll end up with self:SetWeaponHoldType(nil) which you probably don’t want.

Taking out the spaces in the folder name worked, thanks Johnny. Now I just have to work out a few kinks because it’s a little messed up.

mine isnt showing up as well any ideas? this is my codes:SWEP.Author = Whiskey Tango Foxtrot, Kleinz
SWEP.Contact =
SWEP.Purpose = Kill Those Filthy Brits
SWEP.Instructions = Point, Click, Repeat

SWEP.Category = Whiskey’s Rifles

if SERVER then

AddCSLuaFile (“shared.lua”)

SWEP.Weight = 5

SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false

end

elseif CLIENT then

SWEP.PrintName = Austrian-Steyr-Mannlicher-M1895

SWEP.Slot = 3
SWEP.SlotPos = 1

SWEP.DrawAmmo = flase

SWEP.DrawCrosshair = false

end

SWEP.Spawnable = true

SWEP.AdminSpawnable = true

SWEP.IronSightsPos = Vector(-6.6, -16.449, 2.88)
SWEP.IronSightsAng = Vector(2.319, 0.054, 0.039)

SWEP.ViewModelFOV = 54
SWEP.ViewModel = “models/weapons/v_IRifle.mdl”
SWEP.WorldModel = “models/weapons/w_IRifle.mdl”
SWEP.ViewModelFlip = false

SWEP.AutoSwitchTo = true
SWEP.AutoSwitchFrom = false

SWEP.Slot = 3
SWEP.SlotPos = 1

SWEP.UseHands = true

SWEP.HoldType = “crossbow”

SWEP.FiresUnderwater = false

SWEP.DrawCrosshair = false

SWEP.DrawAmmo = true

SWEP.ReloadSound = “sound/epicreload.wav”

SWEP.Base = “weapon_base”

SWEP.Primary.Sound = Sound(“weapons/ak47/ak47-1.wav”)
SWEP.Primary.Damage = 85
SWEP.Primary.TakeAmmo = 1
SWEP.Primary.ClipSize = 5
SWEP.Primary.Ammo = “SMG1”
SWEP.Primary.DefaultClip = 1000
SWEP.Primary.Spread = 0.02
SWEP.Primary.NumberofShots = 1
SWEP.Primary.Automatic = false
SWEP.Primary.Recoil = 0.2
SWEP.Primary.Delay = 1.7
SWEP.Primary.Force = 10
SWEP.Primary.Cone = 0.02

SWEP.Secondary.ClipSize = 0
SWEP.Secondary.DefaultClip = 0
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = “none”

SWEP.CSMuzzleFlashes = true