• Print

Author Topic: Trying to make a command to connect to a server?  (Read 7025 times)

0 Members and 1 Guest are viewing this topic.

Offline allu finally joined fnatic!!!

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Trying to make a command to connect to a server?
« on: July 11, 2015, 06:07:44 pm »
The command I'm trying to make is just a simple command whereby I type !ttt and it connects to my TTT server.

Code: Lua
  1. SendLua([[gui.OpenURL( "www.google.co.uk" )]])
^This line above opens the in-game web browser in the gmod overlay on the google homepage.

Code: Lua
  1. SendLua([[gui.OpenURL( "steam://connect/185.38.148.8:27125" )]])
^This doesn't open the browser and so doesn't open the link and therefore doesn't connect to my server.

If, however I manually open the overlay and paste 'steam://connect/185.38.148.8:27125' into the address bar and press enter, it connects to my server.

Is there a way I can connect to a specific IP address without using 'steam://connect' in the overlay as this does not appear to work with OpenURL?


Thanks,
Sam.
« Last Edit: July 11, 2015, 06:12:32 pm by allu finally joined fnatic!!! »

Offline allu finally joined fnatic!!!

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: Trying to make a command to connect to a server?
« Reply #1 on: July 11, 2015, 06:16:14 pm »
I did find a 'fix' whereby I used tinyurl to shorten the steam://connect link however this isn't the most elegant solution to my problem.


Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Trying to make a command to connect to a server?
« Reply #2 on: July 11, 2015, 07:43:45 pm »
According to GMod wiki, openURL must be a http or https
http://wiki.garrysmod.com/page/gui/OpenURL

If you found a work-around, it's not intended.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Trying to make a command to connect to a server?
« Reply #3 on: July 11, 2015, 09:36:23 pm »
ply:ConCommand("connect 192.168.1.1:25016")

That is all you need.  Remember not to put quotes around the ip address and it will mess up the port.

Offline allu finally joined fnatic!!!

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: Trying to make a command to connect to a server?
« Reply #4 on: July 12, 2015, 05:38:46 am »
ply:ConCommand("connect 192.168.1.1:25016")

That is all you need.  Remember not to put quotes around the ip address and it will mess up the port.

I tried this however it said "FCVAR_SERVER_CAN_EXECUTE prevented server running command: connect" in my console. The connect command is apparently not allowed.
« Last Edit: July 12, 2015, 07:40:08 am by allu finally joined fnatic!!! »

Offline Zmaster

  • Full Member
  • ***
  • Posts: 235
  • Karma: 25
Re: Trying to make a command to connect to a server?
« Reply #5 on: July 12, 2015, 09:07:53 am »
I haven't used it in a while, but I had the same issue you're having with the CAN_EXECUTE thing
I was able to do it by using this code server side:
ply:SendLua( "LocalPlayer():ConCommand( 'connect 123.456.789:27015' ) " )

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Trying to make a command to connect to a server?
« Reply #6 on: July 12, 2015, 03:22:33 pm »
I tried this however it said "FCVAR_SERVER_CAN_EXECUTE prevented server running command: connect" in my console. The connect command is apparently not allowed.
odd, I know there is a way to do it.

  • Print