• Switching servers via buttons (derma)
    3 replies, posted
Hello 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 ("185.38.151.144:27025") I know the server is running, and I don't understand why it won't join it. Here's the bit of code: [LUA] join_sp2_yes.DoClick = function() chat.AddText( Global, Color( 255, 67, 67 ), "[SERVER_PORTAL]:", Color( 255, 255, 255 ), " Joining UG Bhop!" ) RunConsoleCommand( "connect", "185.38.151.144:27025" ) end [/LUA] Any help would be awesome! Thanks, Munch
Make it "connect ipaddress", no comma
[QUOTE=JasonMan34;48439297]Make it "connect ipaddress", no comma[/QUOTE] That's not how RunConsoleCommand works, and even then, everything put in RunConsoleCommand is wrapped in quotes, so it would try to do (connect "185.38.151.144:27025"), which is not a valid IP address. However, this is how you would do it; [lua]LocalPlayer():ConCommand("connect 185.38.151.144:27025")[/lua]
[QUOTE=JasonMan34;48439297]Make it "connect ipaddress", no comma[/QUOTE] As to be expected it then prints this in console. You have to separate it otherwise this happens: RunConsoleCommand: Command has invalid characters! (connect 185.38.151.144:27025 (' ')) The first parameter of this function should contain only the command, the second parameter should contain arguments. [editline]11th August 2015[/editline] [QUOTE=Author.;48439330]That's not how RunConsoleCommand works, and even then, everything put in RunConsoleCommand is wrapped in quotes, so it would try to do (connect "185.38.151.144:27025"), which is not a valid IP address. However, this is how you would do it; [lua]LocalPlayer():ConCommand("connect 185.38.151.144:27025")[/lua][/QUOTE] However yours does work! Thank you :D
Sorry, you need to Log In to post a reply to this thread.