Problem with my addon! Please help!

Hello Facepunch Community,
I had a problem with my Addon. It won’t work!
Heres the Code:

if ( SERVER ) then

AddCSLuaFile( "weapon_chairgun.lua" )


– Basics
SWEP.PrintName = “Chair Launcher”
SWEP.Author = “Felix_Dev”
SWEP:Instructions = “A Chair Launcher who shoot Chairs”
SWEP.Spawnable = true
SWEP.AdminOnly = true
SWEP.Category = “Other”
SWEP.Base = “weapon_cs_base”
SWEP.HoldType = “pistol”

– SWEP Ammo and Clip
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = “none”

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

– SWEP’s more info
SWEP.Weight = 5
SWEP.AutoSwtichTo = false
SWEP.AutoSwitchFrom = false

SWEP.Slot = 1
SWEP.SlotPos = 1
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = true

– SWEP’s Model
SWEP.ViewModel = “models/weapons/v_pistol.mdl”
SWEP.WorldModel = “models/weapons/w_pistol.mdl”

– SWEP’s Sound
local ShootSound = Sound(Metal_SawbladeStick)

– SWEP’s Primary Attack
function SWEP:PrmiaryAttack()
self.Weapon:SetNextPrimaryFire( CurTime() + 0.5 )
self.ThrowChair( “models/props_c17/FurnitureChair001a.mdl” )
function SWEP:ThrowChair( “models/props_c17/FurnitureChair001a.mdl” )
self:EmitSound( ShootSound )

if ( CLIENT ) then return end
local ent = ents.Create( “prop_physics” )
if ( !IsValid( ent ) ) then return end
ent:SetModel( “models/props_c17/FurnitureChair001a.mdl” )
ent:SetPos( self.Owner:EyePos() + ( self.Owner:GetAimVecotr() * 16 ))
ent:SetAngles( self.Owner:EyeAngles() )
local phys = ent:GetPhysicsObject()
if ( !IsValid( phys ) ) then ent:Remove() return end

	   local velocity = self.Owner:GetAimVector()
	   velocity = velocity * 100
	   velocity = velocity + ( VectorRand() * 10 )
	   phys:ApplyForceCenter( velocity )

– Add to Undo List
cleanup.Add( self.Owner, “props”, ent)
undo.Create( “Thrown_Chair” )
undo.AddEntity (ent)
undo.SetPlayer( self.Owner )

Any errors? Also, I would simply place AddCSLuaFile() without the if SERVER stuff.

I would try it.

After revising the code again, I’ve found a couple of things that bugged me:

First: The function SWEP:PrimaryAttack() is not well spelt it says “PrmiaryAttack” instead of “PrimaryAttack”

Second: There’s an function (ThrowChair) which is not properly called.

It’s called with a dot (self.ThrowChair) instead of two (self:ThrowChair).

It won’t work.

I fixed my last reply, check those things out.

Thanks for this reply. But the problem is that it does not appear in the weapons category.

SWEP:Instructions should be SWEP**.**Instructions

There are also a couple more errors that I noticed, but I’m sure you can figure them out yourself :smile:

That’s actually the first time you mentioned an error. If you want us to help, let us know what are the expected results, and what do you get instead [aka errors].

Also, you might need a shared spawn function in order to get it work.

To have the swep appear in the weapons category, there’s a chance you need to make sure that you have client, server and shared lua files together.