Gmod lua help (pro lua coders only please)

I don’t like to steal people’s time and I am quite new here but I was wondering if I could get some help in GLua…I have made a chair gun of some sort that you can load and shoot chairs although I want to make it so that I can right click and have a menu which pops up and gives you a list of props to shoot with, only 4 reloads each.

Please don’t refer me to coderhire as I am a stingy fuck.

Any help would be greatly appreciated!

Thanks for your time!


if SERVER then 
 
	AddCSLuaFile ("shared.lua")
 
	SWEP.Weight = 5
 
	SWEP.AutoSwitchTo = false
	SWEP.AutoSwitchFrom = false
 
elseif CLIENT then 
 
	
	SWEP.PrintName = "Chair throwing gun"
 
	SWEP.Slot = 4
	SWEP.SlotPos = 1
 
	
	SWEP.DrawAmmo = false
 
	
	SWEP.DrawCrosshair = false
 
 
	language.Add("Undone_Thrown_SWEP_Entity","Undone Thrown SWEP Entity")
end
 
SWEP.Author = "MrPlonker"
SWEP.Contact = "plonkeronpc@gmail.com"
SWEP.Purpose = "Throw chairs around!"
SWEP.Instructions = "Right click to bring up a menu of props, left click to fire!"
 

SWEP.Category = "Category"
 
SWEP.Spawnable = true 
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 = false
 
SWEP.Primary.Ammo = "none"
 
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
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:GetEyeTrace()
 
	self:EmitSound(ShootSound)
	self.BaseClass.ShootEffects(self)
 
	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


-snip-

So, you basically want us to make you a thing?

That’s not how this place works.

Not at all…just a lead in the right direction…

Take a look at these: DIconLayout, SpawnIcon, and DScrollPanel, pick the ones you think are most applicable in your situation.
You’d have to make some table to store how many of each you’ve fired, and change which prop is active when any item is clicked.

I saw the thread title and instantly knew this thread was for me: John Lua, standing by.

[lua]local choices = {“im/gay.mdl”, “so/are/you.mdl”}
if SERVER then
net.Receive(“ChooseAChair”, function(len, ply)
ply.ChairChoice = net.ReadUInt(8)
end)

function SWEP:PrimaryAttack()
    local choice = self.Owner.ChairChoice
    choice = choices[choice]

    self:throw_attack(choice)
end

end

if CLIENT then
function SWEP:SecondaryAttack()
blah = vgui.Create(“DFrame”)
button = vgui.Create(“DButton”)
local selection = 1
button.DoClick = function()
net.Start(“ChooseAChair”)
net.WriteUInt(selection, 8)
net.SendToServer()
end
end
end[/lua]

I am not pro enough to reply with code. :frowning:

This isn’t a Michael McIntyre show. Just a bit of friendly help lol…

You’ve got more than enough help already. Beyond that we’d be writing it for you.

If you try to use the advice given and are still having problems then show your code and tell us what’s wrong with it.

^ is this guy even a pro lua coder?


(User was banned for this post ("This isn't helpful" - Grea$eMonkey))

You definitely aren’t.

Not sure why this guy posted however, the thread hadn’t been posted in for 4 days nor did the OP seem to have any more problems.

Yes he is actually he coded many successful servers including the “hunger games” gamemode on Garrys Mod. Very skilled and I have been apart of his community for about a year now. Still doesn’t get boring as he does frequent updates to all servers. Come check us out at www.420servers.com

Thanks for the help everyone!

id try and help you man but idk im not a pro lua coder

Thanks man its cool im trying to work with what i got

Not 420 servers :suicide: I’ve read their code; it’s all just stolen code mashed together into messy file organizations. All of the functions come straight from the wiki too and there’s no defined style. Half of the code uses non-lua operators, semi-colons, and many other things; while the other half doesn’t. Just a suggestion, clean up the code and that’ll fix up the major lag issues.

Also, it’s called 420 servers.

Please get off the internet. It’s a game who gives a fuck? Stop whining.

You give enough of a fuck to give your game server’s plug in this thread.

Then don’t advertise your crappy server then. “Stop whining.”