I currently purchased a new server box under a new IP and I was wondering if it was possible to make a script to put in my old server so that when ever someone joins my old server they will automatically connect to my new one.
PlayerInitialSpawn and pl:ConCommand("connect newip")
or you can just lock the server and change the hostname to "!!!!NEW IP: whatever!!!!"
PlayerInitialSpawn and pl:ConCommand("connect newip") Ended up not working. I placed that in file in lua/autorun
I ended up getting this "FCVAR_SERVER_CAN_EXECUTE prevented server running command: connect"
[QUOTE=phillipsincs;50879442]I ended up getting this "FCVAR_SERVER_CAN_EXECUTE prevented server running command: connect"[/QUOTE]
This should work:
[code]
function Redirect(ply)
ply:SendLua([[RunConsoleCommand("connect", "<INSERT IP HERE>")]])
end
hook.Add("PlayerInitialSpawn", "RedirectClient", Redirect)
[/code]
[QUOTE=hghg1;50879508]This should work:
[code]
function Redirect(ply)
ply:SendLua([[RunConsoleCommand("connect", "<INSERT IP HERE>")]])
end
hook.Add("PlayerInitialSpawn", "RedirectClient", Redirect)
[/code][/QUOTE]
My game ends up crashing after sending client info. I had multiple people try and connect and it crashes there game to.
[QUOTE=phillipsincs;50879872]My game ends up crashing after sending client info. I had multiple people try and connect and it crashes there game to.[/QUOTE]
Learn how to use the net library
server:
[code]
util.AddNetworkString "LeaveThisServerAtOnce"
hook.Add("PlayerInitialSpawn", "Redirect", function(ply)
net.Start "LeaveThisServerAtOnce"
net.Send(ply)
end)
[/code]
client:
[code]
net.Recieve("LeaveThisServerAtOnce", function()
RunConsoleCommand("connect", "ip")
end)
[/code]
This is purely clientside. No networking or server involvement. However, it will be called a little while after PlayerInitialSpawn is called serverside. Pretty much the moment they have control over their character.
[code]
hook.Add( "InitPostEntity", "Redirect", function()
LocalPlayer():ConCommand( "connect <Your IP Here>" )
end )
[/code]
[QUOTE=Mista Tea;50880037]This is purely clientside. No networking or server involvement. However, it will be called a little while after PlayerInitialSpawn is called serverside. Pretty much the moment they have control over their character.
[code]
hook.Add( "InitPostEntity", "Redirect", function()
LocalPlayer():ConCommand( "connect <Your IP Here>" )
end )
[/code][/QUOTE]
Thank you very much. That ended up working.
Sorry, you need to Log In to post a reply to this thread.