Hello again, I was wondering how I can use the value that is gotten from my DComboBox and do something with the player selected, kinda like ULX.
PS: I'm not actually uploading this anywhere, this is my learning thingy (this will be the first thing I create aside from a swep that launches crows at the speed of sound).
Heres my clientside:
local frame = vgui.Create("DFrame")
frame:SetSize(300, 300)
frame:SetVisible(true)
frame:Center()
frame:MakePopup()
frame:SetTitle("Jinx's Admin Test Thingy")
local b = vgui.Create("DButton", frame)
b:SetPos(120, 30)
b:SetSize(75, 20)
b:SetText("God Mode")
function b:DoClick()
net.Start("MessageName")
net.SendToServer()
end
net.Receive("BackMessage", function()
chat.AddText(Color(255, 25, 25), "[SERVER]", Color(255, 255, 255), " ", ply, " Has been godded.")
end)
local comboBox = vgui.Create( "DComboBox", frame )
comboBox:SetPos( 5, 30 )
comboBox:SetSize( 100, 20 )
comboBox:SetValue( "All Players" )
comboBox.OnSelect = function( _, _, value )
print( value.." was selected!" )
end
for k, v in pairs( player.GetAll() ) do
comboBox:AddChoice( v:Name() )
end
and my serverside:
util.AddNetworkString("MessageName")
util.AddNetworkString("BackMessage")
net.Receive( "MessageName", function( len, ply )
if ( IsValid( ply ) and ply:IsPlayer() ) then
print( "Message from " .. ply:Nick() .. " received. Its length is " .. len .. "." )
ply:GodEnable()
net.Start("BackMessage")
net.Send(ply)
end
end )
PSS: Its 6:21 AM so I won't respond if you ask me anything, night!!!
DComboBox/AddChoice 2nd argument takes "data" so you don't have to identify the players using their nicknames (comboBox:AddChoice( v:Name(), v )).
DComboBox/GetSelected returns the name and "data" of the selected field.
If you want to network the player use net.WriteEntity.
Thank you, may I ask also how I would use that in my code? Like how can I send that information to the server? Is it net.ReadEntity? If so what do I put in the parameters. Thank you.
Sorry, you need to Log In to post a reply to this thread.