A SWEP I made, won't show up in Gmod!

I’ve tried almost everything. Help me please!

EDIT:

Ok well I will include bullets in my next swep.

Link for DL: http://www.garrysmod.org/downloads/?a=view&id=86128

Be more descriptive. Sysytem specs, if you have any addons, etc.

Also, posting the code could help.

Ok,Here is the code:

SWEP.base = “weapon_base”
SWEP.Category = “Other”;
SWEP.Author = “Toad”;
SWEP.Contact = “easypweezy@yahoo.com”;
SWEP.Purpose = “Fun”;
SWEP.Instructions = “Left Click For fire, Right Click For Alt fire.”;
SWEP.PrintName = “Toad’s first swep”;
SWEP.Slot = 1;
SWEP.SlotPos = 1;
SWEP.DrawCrosshair = true;
SWEP.DrawAmmo = true;
SWEP.ViewModel = “models/weapons/v_m4.mdl”;
SWEP.WorldModel = “models/weapons/w_m4.mdl”;
SWEP.ViewModelFOV = 64;
SWEP.ReloadSound = “weapons/m4/m4_reload1.wav”;
SWEP.HoldType = “shotgun”;
SWEP.Spawnable = true;
SWEP.AdminSpawnable = true;
SWEP.Weight = 1;
SWEP.AutoSwitchTo = true;
SWEP.AutoSwitchFrom = true;
SWEP.FiresUnderwater = true;

SWEP.Primary.Sound = “weapons/m4/fire1.wav”
SWEP.Primary.Tracer = 1;
SWEP.Primary.Automatic = true;
SWEP.Primary.Force = 300;
SWEP.Primary.FireFromHip = true;
SWEP.Primary.Weld = false;
SWEP.Primary.Ammo = “m4”;
SWEP.Primary.ExplosionShot = false;
SWEP.Primary.BulletShot = true;
SWEP.Primary.ModelShot = false;
SWEP.Primary.BreakAll = true;
SWEP.Primary.Ignite = false;
SWEP.Primary.ClipSize = 1000;
SWEP.Primary.DefaultClip = 1000;
SWEP.Primary.Recoil = 0.00;
SWEP.Primary.Damage = 15;
SWEP.Primary.NumberofShots = 1;
SWEP.Primary.Spread = 1;
SWEP.Primary.Delay = 1;
SWEP.Primary.Model = “models/props_c17/FurnitureChair001a.mdl”;
SWEP.Primary.ExplosionSound = “weapon_AWP.Single”;
SWEP.Primary.ExplosionSoundDistance = 400;
SWEP.Primary.ExplosionSize = 175;
SWEP.Primary.TakeAmmo = 1;

SWEP.Secondary.Sound = “weapons/ar2/fire1.wav”
SWEP.Secondary.Tracer = 1;
SWEP.Secondary.Force = 640;
SWEP.Secondary.Automatic = false;
SWEP.Secondary.FireFromHip = true;
SWEP.Secondary.Weld = false;
SWEP.Secondary.ExplosionShot = true;
SWEP.Secondary.BulletShot = false;
SWEP.Secondary.ModelShot = false;
SWEP.Secondary.BreakAll = true;
SWEP.Secondary.Ignite = false;
SWEP.Secondary.Recoil = 0.00;
SWEP.Secondary.Spread = 3;
SWEP.Secondary.Delay = 3;
SWEP.Secondary.TakeAmmo = 1;
SWEP.Secondary.Model = “models/props_c17/FurnitureChair001a.mdl”;
SWEP.Secondary.ExplosionSound = “weapon_AWP.Single”;
SWEP.Secondary.ExplosionSoundDistance = 400;
SWEP.Secondary.ExplosionSize = 175;

function SWEP:Initialize()
util.PrecacheSound(self.Primary.Sound);
util.PrecacheSound(self.Secondary.Sound);
if ( SERVER ) then
self:SetWeaponHoldType( self.HoldType );
end
end

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

//Default stuff, normally used in any condition.
local trace = self.Owner:GetEyeTrace();
self.Weapon:EmitSound ( self.Primary.Sound );
self:ShootEffects();
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay );
self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay ); self:TakePrimaryAmmo(self.Primary.TakeAmmo);
local rnda = -self.Primary.Recoil;
local rndb = self.Primary.Recoil * math.random(-1, 1);
self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) );

//The attack mode, can vary from the user settings
if ( self.Primary.ExplosionShot ) then
local explode = ents.Create( “env_explosion” );
explode:SetPos( trace.HitPos );
explode:SetOwner( self.Owner );
explode:Spawn();
explode:SetKeyValue( “iMagnitude”, self.Primary.ExplosionSize );
explode:Fire( “Explode”, 0, 0 );
explode:EmitSound( self.Primary.ExplosionSound, self.Primary.ExplosionSoundDistance, self.Primary.ExplosionSoundDistance );
end
if ( self.Primary.BreakAll ) then
if( trace.Entity:IsValid() and trace.Entity:GetClass() == “prop_physics” ) then
constraint.RemoveAll( trace.Entity );
local physobject = trace.Entity:GetPhysicsObject();
physobject:EnableMotion( true );
physobject:SetVelocity( self.Owner:GetAimVector() * 2 );
end
end
if ( self.Primary.Ignite ) then
if (!trace.Entity) then return false end
if (!trace.Entity:IsValid() ) then return false end
if (trace.Entity:IsPlayer()) then return false end
if (trace.Entity:IsWorld()) then return false end
if ( CLIENT ) then return true end
local Time = math.random(20);
trace.Entity:Extinguish();
trace.Entity:Ignite( Time, 0 );
end
if ( self.Primary.BulletShot ) then
local bullet = {};
bullet.Num = self.Primary.NumberofShots;
bullet.Src = self.Owner:GetShootPos();
bullet.Dir = self.Owner:GetAimVector();
bullet.Spread = Vector( self.Primary.Spread * 0.1 , self.Primary.Spread * 0.1, 0);
bullet.Tracer = self.Primary.Tracer;
bullet.Force = self.Primary.Force;
bullet.Damage = self.Primary.Damage;
bullet.AmmoType = self.Primary.Ammo;
self.Owner:FireBullets( bullet );
end
if ( self.Primary.ModelShot ) then
if (!SERVER) then return end;
local ent = ents.Create (“prop_physics”);
ent:SetModel ( self.Primary.Model );
if ( self.Primary.FireFromHip ) then
ent:SetPos (self.Owner:EyePos() + (self.Owner:GetAimVector() * 32));
else
ent:SetPos (trace.HitPos + self.Owner:GetAimVector() * -16);
end
ent:SetAngles (self.Owner:EyeAngles());
ent:Spawn();
local phys = ent:GetPhysicsObject();
local shot_length = trace.HitPos:Length();
if ( self.Primary.Weld ) then
local weld = constraint.Weld( trace.Entity, ent, trace.PhysicsBone, 0, 0 );
end
phys:ApplyForceCenter (self.Owner:GetAimVector():GetNormalized() * math.pow (shot_length, 3));
cleanup.Add (self.Owner, “props”, ent);
undo.Create (“Thrown model”);
undo.AddEntity (ent);
undo.SetPlayer (self.Owner);
undo.Finish();
end
end

[editline]06:54PM[/editline]

From the code,maybe I forgot to code somthing?

did u make a folder, put the lua inside that folder, put ur custom folder inside lua>weapons?

Yeah, make sure that you put a folder inside lua\weapons. Preferably called Toad or something simple.
Then make sure that the lua file that code is in is called shared.lua

So wait… You mean it has to be called shared.lua? i just put it named shared…

[editline]06:45PM[/editline]

i changed the name of the lua to shared.lua now i will try it.

I think ive done everything, the name is shared,the file is Toad…it wont show up? wtf…!

On the future note - Put the codes in


 tags.

This all worked thanks guys,but…It shows up as the red thingys and doesnt shoot right and goes all slow to shoot different things

That’s the swep, not gmod

That wasn’t smart…posting the code. People could copy it :I

But maby its just a luacode error…you know. The coding error that kills everything happy and nice? Yesh, that one…

Give one good reason why someone should copy a code that doesnt work right now instead of copying a masterful SWEP?

Yeah…Anyways it still doesnt work…I might give up. it shows the red things for the weapon

That means you wrote the model paths wrong.
Try v_rif_m4a1.mdl instead of v_m4.mdl and w_rif_m4a1.mdl instead of w_m4.mdl

Ok thanks, now it works, one thing, i want it to fire bullets not chairs…any ideas?

CHAIRS? :cawg:

Yeah. Its my first swep like it or gtfo

That would need a totally different LUA code. I think there was one in the Gmod Wiki.