ULX

Author Topic: Server Redirect (Command & Auto)  (Read 18267 times)

0 Members and 1 Guest are viewing this topic.

Offline goodman854

  • Newbie
  • *
  • Posts: 14
  • Karma: 2
Server Redirect (Command & Auto)
« on: February 06, 2014, 02:23:22 PM »
Either from ULX or as a script in autorun, I'd like to have members of my server be instantly redirected from the server when they join to another or have the whole server redirected when I run a ulx command that forces such to happen.

I'd like to do this on my own if possible. I just need a little help to start.

So what is wrong with the following:
Code: [Select]
--autorun/redirect.lua
if SERVER then
AddCSLuaFile"autorun/redirect.lua"
else
LocalPlayer():ConCommand("connect IP")
end

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Server Redirect (Command & Auto)
« Reply #1 on: February 06, 2014, 03:07:13 PM »
Either from ULX or as a script in autorun, I'd like to have members of my server be instantly redirected from the server when they join to another or have the whole server redirected when I run a ulx command that forces such to happen.

I'd like to do this on my own if possible. I just need a little help to start.

So what is wrong with the following:
Code: [Select]
--autorun/redirect.lua
if SERVER then
AddCSLuaFile"autorun/redirect.lua"
else
LocalPlayer():ConCommand("connect IP")
end

As far as I know the command "connect" is blocked by Garry.
I cry every time I see that I am not a respected member of this community.

Offline goodman854

  • Newbie
  • *
  • Posts: 14
  • Karma: 2
Re: Server Redirect (Command & Auto)
« Reply #2 on: February 06, 2014, 04:59:23 PM »
As far as I know the command "connect" is blocked by Garry.
There are sever hopper addons though... so it is possible some how.

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Server Redirect (Command & Auto)
« Reply #3 on: February 06, 2014, 05:47:16 PM »
ply:SendLua( [[RunConsoleCommand( "connect", "ip.address.goes.here" )]] )

Offline goodman854

  • Newbie
  • *
  • Posts: 14
  • Karma: 2
Re: Server Redirect (Command & Auto)
« Reply #4 on: February 06, 2014, 06:54:06 PM »
ply:SendLua( [[RunConsoleCommand( "connect", "ip.address.goes.here" )]] )
Sadly I tried that and it does not appear to be working.

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Server Redirect (Command & Auto)
« Reply #5 on: February 06, 2014, 06:56:26 PM »
Sadly I tried that and it does not appear to be working.
Works for me.

Offline goodman854

  • Newbie
  • *
  • Posts: 14
  • Karma: 2
Re: Server Redirect (Command & Auto)
« Reply #6 on: February 06, 2014, 07:10:49 PM »
Works for me.
Would I need to restart the server? Is a map change not sufficient?

Offline Neku

  • Hero Member
  • *****
  • Posts: 549
  • Karma: 27
Re: Server Redirect (Command & Auto)
« Reply #7 on: February 06, 2014, 08:35:04 PM »
Well, are you just putting that one line of code in?

Or did you actually implement that into a command or something?
Out of the Garry's Mod business.

Offline goodman854

  • Newbie
  • *
  • Posts: 14
  • Karma: 2
Re: Server Redirect (Command & Auto)
« Reply #8 on: February 07, 2014, 04:36:16 AM »
Well, are you just putting that one line of code in?

Or did you actually implement that into a command or something?
I added this lua file to the lua/autorun of the server
Code: [Select]
--goes in autorun/redirect.lua
if SERVER then
AddCSLuaFile"autorun/redirect.lua"
else
ply:SendLua( [[RunConsoleCommand( "connect", "THE IP" )]] )
end

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Server Redirect (Command & Auto)
« Reply #9 on: February 07, 2014, 05:11:50 AM »
I added this lua file to the lua/autorun of the server
Code: [Select]
--goes in autorun/redirect.lua
if SERVER then
AddCSLuaFile"autorun/redirect.lua"
else
ply:SendLua( [[RunConsoleCommand( "connect", "THE IP" )]] )
end
Since you don't have ply defined, replace it with LocalPlayer() and try that.
bw81@ulysses-forums ~ % whoami
Homepage

Offline goodman854

  • Newbie
  • *
  • Posts: 14
  • Karma: 2
Re: Server Redirect (Command & Auto)
« Reply #10 on: February 07, 2014, 06:17:54 AM »
Since you don't have ply defined, replace it with LocalPlayer() and try that.
Didn't work but... I am getting this:

Code: [Select]
clientside lua startup!
Lua JIT is DISABLED!
TEST [lua/autorun/gmt_playermodels.lua][lua/autorun/redirect.lua]

[ERROR] lua/autorun/redirect.lua:5: attempt to call method 'SendLua' (a nil value)
  1. unknown - lua/autorun/redirect.

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Server Redirect (Command & Auto)
« Reply #11 on: February 07, 2014, 07:58:07 AM »
Dude what are you doing, you can't just put it in there without any other code and expect it to do exactly what you want it to do. also you need an actual IP address...
make it a function and have the client call the function when they want to switch servers, or get a derma menu and a button to make the player join the server.
On top of that, sendlua is a server side function. No need for it on the client side.

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given