Switching servers via buttons (derma)


So I’m creating a server portal menu. It shows servers and if you click the button ‘Connect’ it will join that server however. When I click the button it just prints this in console: Bad server address (“”)

I know the server is running, and I don’t understand why it won’t join it. Here’s the bit of code:

join_sp2_yes.DoClick = function()
chat.AddText( Global, Color( 255, 67, 67 ), “[SERVER_PORTAL]:”, Color( 255, 255, 255 ), " Joining UG Bhop!" )
RunConsoleCommand( “connect”, “” )

Any help would be awesome! Thanks, Munch

Make it “connect ipaddress”, no comma

That’s not how RunConsoleCommand works, and even then, everything put in RunConsoleCommand is wrapped in quotes, so it would try to do (connect “”), which is not a valid IP address.

However, this is how you would do it;


As to be expected it then prints this in console. You have to separate it otherwise this happens:

RunConsoleCommand: Command has invalid characters! (connect (’ '))
The first parameter of this function should contain only the command, the second parameter should contain arguments.

[editline]11th August 2015[/editline]

However yours does work! Thank you :smiley: