Hi all,
I need assistance getting this setup to re-direct people that connect to the old server to the new one. Code I have:
[CODE]if SERVER then
AddCSLuaFile"autorun/redirect.lua"
else
hook.Add("InitPostEntity","redirect",function() RunConsoleCommand("connect", "192.228.110.103:27015") end)
end[/CODE]
When tested and I join the old server, it crashes my game once it's done "Sending client info" any help?
I wouldn't use InitPostEntity for redirecting. Use gameevent.Listen with player_connect or PlayerInitialSpawn.
That method no longer works as it's blocked. I bypassed this by using player send Lua instead and it works with no problems.
Also use PlayerInitialSpawn when you use send Lua
Ugh I've little to no experience with LUA and need this quick. What am I doing wrong?
[CODE]gameevent.Listen( "player_connect" )
hook.Add( "player_connect, "redirect", function()
ply:SendLua("LocalPlayer():ConCommand('connect 192.228.110.103')")
end[/CODE]
[QUOTE=Hollistupid;45405863]Ugh I've little to no experience with LUA and need this quick. What am I doing wrong?
[CODE]gameevent.Listen( "player_connect" )
hook.Add( "player_connect, "redirect", function()
ply:SendLua("LocalPlayer():ConCommand('connect 192.228.110.103')")
end[/CODE][/QUOTE]
Almost everything...
You should use a structure like this:[CODE] if SERVER then
hook.Add('PlayerInitialSpawn','Redirecttoserver',function(ply)
--(your Lua Send stuff function here)
print('redirected '..ply:Nick()) --add this into check if a player get's redirected
end)
end)
end[/CODE]
Sorry, you need to Log In to post a reply to this thread.