Server connect to another server

Does anyone know how to make it so that when you join a server it connects you to another server automaticly?

[lua]
hook.Add(“PlayerSpawn”, “connect_elsewhere”, function(ply)
ply:ConCommand(“connect SERVER_IP_HERE”)
end)
[/lua]

This needs to be on the serverside, by the by.

Will throw an engine error. You need to tell the client from the server to run the command.

[editline]21st January 2012[/editline]

hook.Add(“InitPostEntity” , 0 , function() LocalPlayer():ConCommand(“connect x”) end )

The command is blocked from being run via lua on the clientside. Doesn’t throw up any error when I used it a few minutes ago, may be different for a server. I also used a loop method as opposed to just pulling the player from the function parameters. Try both, see which one works.

[editline] lol [/editline]
The command may also be run too early, and I guess that’s what might cause the error. Meh, hooks. Still, serverside command is required.

There is no required serverside portion. My code works; yours didn’t last time I tried it (~2010). Pretty sure it was a SERVER_CANNOT_EXECUTE flag.

I concede, if it works it works. Now I just have to reason out why Garry would apply restrictions to RunConsoleCommand() but not to LocalPlayer():ConCommand().

Thats not telling the client from the server, thats just doing everything from the client.

The server has to send the file, therefore is (indirectly) telling the client.