Author Topic: Need help debugging Garry's Mod addon  (Read 2004 times)

Here's my code:

Quote
SWEP.Author = Elecro
SWEP.Contact = "N/A"
SWEP.Purpose = "Throw chairs at people lol"
SWEP.Instructions = "Press the left mouse button and fire!!!"

SWEP.Category = "Chair Throwing Devices"

SWEP.Spawnable = false
SWEP.AdminSpawnable = true

SWEP.ViewModel = "models/weapons/v_RPG.mdl"
SWEP.WorldModel = "models/weapons/w_rocket_launcher.mdl"

SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = true
SWE.Primary.Ammo = "none"

SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = true
SWEP.Secondary.Ammo = "none"

local ShootSound = Sound(Metal.SawbladeStick)

function SWEP:Reload()
end
 
function SWEP:Think()
end

function SWEP:throw_attack (model_file)

   local tr = self.Owner:GetEyeTrack()

   self:EmitSound(ShootSound)
   self.BaseClass.ShootEffects(self)

   //We now exit if this function is not running serverside

   if (!SERVER) then return end
   
   local ent = ents.Create("prop_physics")
   ent:SetModel(model_file)
   
   ent:SetPos(self.Owner:EyePos() + (self.Owner:GetAimVector() * 16))
   ent:SetAngles(self.Owner:EyeAngles())
   ent:Spawn()
   
   local phys = ent:GetPhysicsObject()
   
   if !(phys && IsValid(phys)) then ent:Remove() return end
   
   phys:ApplyForceCenter)self.Owner:GetAimVector():GetNormalized() * math.pow(tr.HitPos:Length(), 3))
   
   cleanup.Add(self.Owner, "props", ent)
   
   undo.Create ("Thrown_SWEP_Entity")
      undo.AddEntity (ent)
      undo.SetPlayer (self.Owner)
   undo.Finish()
end

function SWEP:PrimaryAttack()
   self:throw_attack("models/props/cs_office/Chair_office.mdl")
end

function SWEP:SecondaryAttack()
   self:throw_attack("models/props_c17/FurnitureChair001a.mdl")
end
   
   
//Here we begin with the server and client shi

if SERVER then //Where the init.lua stuff goes.

//Makes sure clientss download the file
AddCSLuaFile("shared.lua")

//How heavy the weapon is
SWEP.Weight = 5

//Allow switching to/from when weapons are picked up
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false

elseif CLIENT then //Where cl_init.lua stuff goes

//Name of SWEP, as appearing in the weapon tab in the spawn menu
SWEP.PrintName = "Mr. Chair Thrower"

//Sets where the weapon is found in the switching menu
SWEP.Slot = 3
SWEP.SlotPos = 2

//Drawing ammunition for the weapon
SWEP.DrawAmmo = false

//Sets the crosshair when weapon is deployed
SWEP.DrawCrosshair = false

//Ensures a clean looking notification when a chair is undone, how it works:
//When you create an undo, you specify the ID:
//   undo.Create("Some_Indentity)
//By creating an associated language, we can make the undo notification look better:
//   language.Add("Undone_Some_Identity", "Message")

   language.Add("Undone_Thrown_SWEP_Entity, "Undone Thrown SWEP Entity")

end

Someone told me you could put everything in shared.lua so I did, I tried to put them in the proper places and that didn't work either. I checked over, I didn't see and grammar errors. Could someone help me?

that looks like a mess of a script
although i don't script anymore so idk

that looks like a mess of a script

Do you mean that its not organized or badly done?

Do you mean that its not organized or badly done?
idk, it just looks like a mess cuz i dont understand it

idk, it just looks like a mess cuz i dont understand it
then you shouldn't call it messy

idk, it just looks like a mess cuz i dont understand it

do u even lua?

If you have a Facepunch account, you can ask there, you're more guaranteed to get rated dumb a bunch of times more help than here

If you have a Facepunch account, you can ask there, you're more guaranteed to get rated dumb a bunch of times more help than here

those guys are legit jackasses.

those guys are legit jackasses.
In my 3 years of being on Facepunch, i haven't actually seen as much mean people as i've heard, i guess it's just a matter of who you get

The post ratings don't matter unless you're actually asking for criticism

In my 3 years of being on Facepunch, i haven't actually seen as much mean people as i've heard, i guess it's just a matter of who you get

The post ratings don't matter unless you're actually asking for criticism

i had a account

EDIT: turns out i was ip-ed