I want to use my DComboBoxes to give users Attachments from FAS
heres the code that i want help with
[CODE]
local PANEL = {}
function PANEL:Init()
local Frame = vgui.Create("DFrame",self)
Frame:SetTitle("")
Frame:SetSize(600,380)
Frame:Center()
Frame.btnMaxim:Hide()
Frame.btnMinim:Hide()
Frame:MakePopup()
Frame:SetBackgroundBlur(true)
Frame:SetDraggable(false)
Frame.Paint = function()
draw.RoundedBox( 8,0,0, Frame:GetWide(),Frame:GetTall(),Color(49,49,49,200))
end
local Attach = vgui.Create( "DComboBox", Frame)
Attach:SetPos(5,88)
Attach:SetSize( 88, 20 )
Attach:AddChoice("Bipod")
Attach:AddChoice("M21 Mag")
Attach:AddChoice("SKS Mag")
local Attach2 = vgui.Create( "DComboBox", Frame)
Attach:SetPos(5,108)
Attach:SetSize( 108, 20 )
Attach:AddChoice("Suppresor")
Attach:AddChoice("Foregrip")
Attach:AddChoice("CompM4 Sight")
local Button = vgui.Create("DButton",Frame)
Button:Center()
Button:SetSize(10,10)
Button:SetText("Confirm")
Button.Doclick = function()
-- Get the selected options from Attach and Attach2 and give them to you
end
vgui.Register( "TestDerma", PANEL ) -- you need to register it to open it later
concommand.Add("test",function()
vgui.Create("TestDerma") -- like so
end)
[/CODE]
And what i want is for example you select Bipod and Suppresor it will give you
fas2_att_harrisbipod andfas2_att_suppressor
Any help is greatly appreciated!
I am not sure about combo box because I rarely use it, but if it's like DMenu then you can do:
[lua]DComboBox:AddChoice( "something", function()
--code
end )[/lua]
Ofcourse, you can't give weapons without networking, so in place of --code you would have to place:
[lua]net.Start( 'nwstringhere' )
net.WriteString( 'weapon_name' )
net.SendToServer() [/lua]
It's just an example, you have to make your own networking, here is the guide: [url]http://wiki.garrysmod.com/page/Net_Library_Usage[/url]
[QUOTE=Netheous;44109740]I am not sure about combo box because I rarely use it, but if it's like DMenu then you can do:
[lua]DComboBox:AddChoice( "something", function()
--code
end )[/lua]
Ofcourse, you can't give weapons without networking, so in place of --code you would have to place:
[lua]net.Start( 'nwstringhere' )
net.WriteEntity( LocalPlayer() )
net.WriteString( 'weapon_name' )
net.SendToServer() [/lua]
It's just an example, you have to make your own networking, here is the guide: [url]http://wiki.garrysmod.com/page/Net_Library_Usage[/url][/QUOTE]
You don't have to write "LocalPlayer()" when the 2nd argument in serverside's "net.Receive" is the player who sent it.
[QUOTE=Netheous;44109740]I am not sure about combo box because I rarely use it, but if it's like DMenu then you can do:
[lua]DComboBox:AddChoice( "something", function()
--code
end )[/lua]
Ofcourse, you can't give weapons without networking, so in place of --code you would have to place:
[lua]net.Start( 'nwstringhere' )
net.WriteEntity( LocalPlayer() )
net.WriteString( 'weapon_name' )
net.SendToServer() [/lua]
It's just an example, you have to make your own networking, here is the guide: [url]http://wiki.garrysmod.com/page/Net_Library_Usage[/url][/QUOTE]
Yes but i want the data to be read when someone press the "Submit, Confirm, Save" whatever you want to call it button this runs the give command when the click the box, allowing the player to give themself everyone attachment if im right
[QUOTE=brandonj4;44109770]You don't have to write "LocalPlayer()" when the 2nd argument in serverside's "net.Receive" is the player who sent it.[/QUOTE]
Ah, yes, pardon me, I'll change it now.
Bump,
[QUOTE]Yes but i want the data to be read when someone press the "Submit, Confirm, Save" whatever you want to call it button this runs the give command when the click the box, allowing the player to give themself everyone attachment if im right[/QUOTE]
Sorry, you need to Log In to post a reply to this thread.