Connecting a player to another server before spawning

Hi.

Is it possible to force a player to connect to another server before they spawn?

From researching it a bit it seems that there a few hooks called before player initial spawn:
GM:CheckPassword and player_connect

After using a hook with those I could simply do

LocalPlayer():ConCommand(“connect 123456789:27015”)

Is there any way to do this?

Else I guess the next best thing would have to PlayerInitialSpawn.

Thanks in advance.

Something like this may work.
[lua]
hook.Add(“PlayerConnect”, “ConnectToServer2”, function(ply)
ply:ConCommand(“connect 123456789:27015”)
end)
[/lua]

tbh i would go into your gamemode files and find the gm:initialspawn and add your concommand line

edit: ah shoot sorry i just realized you want it before spawn

Thanks, but I was just taking at the PlayerConnect hook and saw this:

GM:PlayerConnect( string name, string ip )

Wouldn’t that mean that your function(ply) wouldn’t work?

Snip

It wont work because when PlayerConnect is called the players object isn’t actually in the server yet. You’re going to have to do it in PlayerInitialSpawn.

I was afraid of that… I wasn’t sure if it was actually added yet, but decided to go along with it. :c

[lua]
hook.Add(“PlayerInitialSpawn”, “ConnectToServer2”, function(ply)
ply:ConCommand(“connect 124059101:1394901”)
end)
[/lua]

I don’t know why you would want this…I had afew lua hackers come on afew days ago and got everyone in my server to connector to theirs, what’s the purpose? If they’re in your server why redirect