Author Topic: Server Redirect (Command & Auto)  (Read 15419 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.

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Server Redirect (Command & Auto)
« Reply #12 on: February 07, 2014, 02:42:58 PM »
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.
Now that I think about it, try this:
Code: Lua
  1. --goes in autorun/redirect.lua
  2. while true do
  3.     BroadcastLua( [[RunConsoleCommand( "connect", "THE IP" )]] )
  4. end
bw81@ulysses-forums ~ % whoami
Homepage

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Server Redirect (Command & Auto)
« Reply #13 on: February 07, 2014, 03:23:33 PM »
Now that I think about it, try this:
Code: Lua
  1. --goes in autorun/redirect.lua
  2. while true do
  3.     BroadcastLua( [[RunConsoleCommand( "connect", "THE IP" )]] )
  4. end
I sincerely hope this is a joke
« Last Edit: February 07, 2014, 05:23:15 PM by Cobalt »

Offline Eccid

  • Full Member
  • ***
  • Posts: 115
  • Karma: 11
  • Hey, come on... We just met...
    • Terror Abound! Steam Group
Re: Server Redirect (Command & Auto)
« Reply #14 on: February 07, 2014, 03:58:03 PM »
The issue here is that nothing is calling any of this. I don't even get what twilight is trying to do. When is this supposed to happen? For example, if I want someone to type "!newserver" into chat and be redirected to the new server, it would go like this.

Code: [Select]
hook.Add( "PlayerSay", "TTN Chat Commands", function(ply, text)
if (string.lower(text) == "!newserver" ) then --Did the player say the specific command?
ply:SendLua([[RunConsoleCommand("connect", "IP.ADRESS.GOES.HERE")]])--Replace IP.ADRESS.GOES.HERE with real IP
return "" --Keeps chat box from printing command
end
end)

Put that in lua\autorun\server and it will allow people to connect.

What way are you wanting to call this?