Client Side Console

How would one go abouts using a function like RunConsoleCommand("")
to do a connect command? Etc: Player presses DButton and the DoClick forces them to “connect 100.100.1.1”?


function Connect()
 
    local DermaPanel = vgui.Create( "DFrame" )
    DermaPanel:SetPos( 50, 50 )
    DermaPanel:SetSize( 500, 500 )
    DermaPanel:SetTitle( "Our Servers" )
    DermaPanel:SetVisible( true )
    DermaPanel:SetDraggable( true )
    DermaPanel:ShowCloseButton( true )
 
    local DermaButton1 = vgui.Create( "DButton" )
    DermaButton1:SetParent( DermaPanel )
    DermaButton1:SetText( "Sandbox" )
    DermaButton1:SetPos( 25, 50 )
    DermaButton1:SetSize( 150, 50 )
    DermaButton1.DoClick = function () -- This is DoClick
        RunConsoleCommand( "connect 1.1.1.1" )
    end
end
 
concommand.Add("serverlist", Connect) -- serverlist is the command to open this panel

Whenever you type serverlist in console then it brings up the menu titled Our Servers.
When you click on “SandBox” it will run connect 1.1.1.1 in the clients console.

No it won’t; it will give a “Bad argument #1 to RunConsoleCommand”.

Instead do

[lua]player:ConCommand(“wait 1;connect IP”)[/lua]

Actually it’s:
[lua]
RunConsoleCommand(“connect”, “1.1.1.1”)
[/lua]
:eng101:

LocalPlayer():ConCommand() works fine too.

2 words.
“Head Asplode”.

Putting a valid IP in there will cause an error about a malformed IP.

:eng101:

wat.