Server Switcher

Hello, im looking for a derma menu where you can select a server from a list, and it will connect you to one. and to open the menu by sayin “/servers” any help would be greatly appreciated :slight_smile:



I can do this, but do you want buttons that connect you to a certain server, Or something else?

[lua]local DermaPanel = vgui.Create( “DFrame” )
DermaPanel:SetPos( 50,50 )
DermaPanel:SetSize( 200, 250 )
DermaPanel:SetTitle( “connect to other server” )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( true )

local DermaButton = vgui.Create( “DButton” )
DermaButton:SetParent( DermaPanel )
DermaButton:SetText( “Some server” )
DermaButton:SetPos( 25, 50 )
DermaButton:SetSize( 150, 50 )
DermaButton.DoClick = function ()
LocalPlayer():ConCommand( “connect” )–server ip here

Don’t forget to include the function. -.-

and actually, a better way to do it is:
hook.Add(“PlayerSay”, “Cmd”, function(pl,text)
if string.find(text, string.sub( “/connect”, 1) ) then
pl:ConCommand( string.sub( text, 2 ) ) return false
I’ve just tested it, and it works.

cool thanks guys


is this server side or client side, + if i wanted more than one server how would it look?


  • can you tell me what to put the codes in and where please

im posting this on behalf of flapjack

that’s a good way to do it :stuck_out_tongue:

The code appears to have been wrecked by copy/pasting.

Now I’m unbanned, here it is.

[lua]// I would post this myself but unfortunately I’m banned.

local servers = { {name = “My server” , IP = “” },
{name = “My other server” , IP = “”}

concommand.Add(“servermenu” , function()

local dframe = vgui.Create("DFrame")
dframe:SetSize(ScrW() / 2 , ScrH() / 3)
dframe:SetTitle("Server Switcher")

local dlistview = vgui.Create("DListView")
dlistview:SetPos(0 , 22)

for k , v in pairs(servers) do
	dlistview:AddLine( , v.IP)

dlistview.OnRowSelected = function(self , row)
	LocalPlayer():ConCommand("connect "..self:GetLine(row):GetValue(2))

end )[/lua]

thank you flapjack :slight_smile:

Forgot to SetSize the DListView. Just realised. Just pop in dlistview:SetSize(ScrW() / 2 , ScrH() / 3 - 22)