Search code examples
luaquotesgarrys-mod

Garry's Mod RunConsoleCommand() does not work correctly


I want to let some friends connect to my server just by clicking a simple button in the Garry's Mod menu. To do that I have added some code to the mainmenu.lua file of Garry's mod. The Button and all other things work, only the RunConsoleCommand("connect", "mycoolgmodserverip.com") fails... In the Console I can find the error Bad server address ("mycoolgmodserverip.com") like when I would type connect "mycoolgmodserverip.com" in the console. But I have to remove the quotes... It does not work with RunConsoleCommand("connect", 'mycoolgmodserverip.com') too.. Do you have any idea?


Solution

  • According to the Garry's Mod source code, you may call JoinServer in the menu state.

    Examples:

    JoinServer(address) JoinServer("myepicserverip.com")