• Print

Author Topic: Stupidest question  (Read 4492 times)

0 Members and 1 Guest are viewing this topic.

Offline Unknown Gamer

  • Jr. Member
  • **
  • Posts: 79
  • Karma: -2
    • TrueKnife TTT
Stupidest question
« on: March 16, 2015, 05:43:51 pm »
Hi,

So I found a server hopper. Works great! (I know how to make one sorta, don't know how to fetch map logo) anyway, It works great except, it only comes with a console command. So I made a ULX command and it doesn't work. All it is supposed to do is a simple RunConsoleCommand. Though it does not work!

It appears in  ULX menu but when I run the command, it does nothing! Any help?
Code: Lua
  1. local CATEGORY_NAME = "BDG TTTs"
  2.  
  3. function ulx.hopper()
  4.         RunConsoleCommand('serverhopping')
  5. end
  6.  
  7. local hopper = ulx.command( CATEGORY_NAME, "ulx hopper", ulx.hopper, "!hop", true )
  8. hopper:defaultAccess( ULib.ACCESS_ALL )
  9. hopper:help( "Swith to a different server." )

Newb Coder. Soon to get better

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Stupidest question
« Reply #1 on: March 16, 2015, 07:04:59 pm »
As far as I know, you can't do that. You're calling that on the server, not the client.
It's probably inefficient, but the way I did it was as follows:

Code: Lua
  1. if SERVER then
  2.     util.AddNetworkString("cl_openserverhoppermenu") -- long name to prevent conflicts
  3. end
  4.  
  5. if CLIENT then
  6.     net.Receive("cl_openserverhoppermenu",
  7.     function (ply)
  8.         RunConsoleCommand("serverhopping")
  9.     end)
  10. end
  11.  
  12. function ulx.hopper(calling_ply)
  13.     net.Start("cl_openserverhoppermenu")
  14.     net.Send(calling_ply)
  15. end
  16.  
  17. -- code to add command to ulx here
bw81@ulysses-forums ~ % whoami
Homepage

Offline Unknown Gamer

  • Jr. Member
  • **
  • Posts: 79
  • Karma: -2
    • TrueKnife TTT
Re: Stupidest question
« Reply #2 on: March 16, 2015, 07:21:17 pm »
As far as I know, you can't do that. You're calling that on the server, not the client.
It's probably inefficient, but the way I did it was as follows:

Code: Lua
  1. if SERVER then
  2.     util.AddNetworkString("cl_openserverhoppermenu") -- long name to prevent conflicts
  3. end
  4.  
  5. if CLIENT then
  6.     net.Receive("cl_openserverhoppermenu",
  7.     function (ply)
  8.         RunConsoleCommand("serverhopping")
  9.     end)
  10. end
  11.  
  12. function ulx.hopper(calling_ply)
  13.     net.Start("cl_openserverhoppermenu")
  14.     net.Send(calling_ply)
  15. end
  16.  
  17. -- code to add command to ulx here
I remember doing this once. Though it was like 3 months ago. I do not remember needing to setup networks. Ill give it a try though!
Newb Coder. Soon to get better

Offline Unknown Gamer

  • Jr. Member
  • **
  • Posts: 79
  • Karma: -2
    • TrueKnife TTT
Re: Stupidest question
« Reply #3 on: March 16, 2015, 07:58:55 pm »
It works! Thanks man! IDK why I need to use networks now but ya!
Newb Coder. Soon to get better

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Stupidest question
« Reply #4 on: March 16, 2015, 08:14:28 pm »
ULX commands may be shared, but they only run serverside.  That's why your version wouldn't work.  You were basically telling the server to run the command.

You could also use this and you wouldn't have to use all the net library stuff.
http://wiki.garrysmod.com/page/Player/ConCommand

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Stupidest question
« Reply #5 on: March 16, 2015, 08:45:17 pm »
ULX commands may be shared, but they only run serverside.  That's why your version wouldn't work.  You were basically telling the server to run the command.

You could also use this and you wouldn't have to use all the net library stuff.
http://wiki.garrysmod.com/page/Player/ConCommand
lel forgot about that function
bw81@ulysses-forums ~ % whoami
Homepage

Offline Unknown Gamer

  • Jr. Member
  • **
  • Posts: 79
  • Karma: -2
    • TrueKnife TTT
Re: Stupidest question
« Reply #6 on: March 19, 2015, 06:11:47 am »
ULX commands may be shared, but they only run serverside.  That's why your version wouldn't work.  You were basically telling the server to run the command.

You could also use this and you wouldn't have to use all the net library stuff.
http://wiki.garrysmod.com/page/Player/ConCommand

Of course I forgot about that! Why why why! Stupid me. Thanks for the index
Newb Coder. Soon to get better

  • Print