Benevolence Posted October 3, 2011 Share Posted October 3, 2011 So I want to make it so if the player logs out, it reconnects him to the server. There's a /reconnect command I can just make it triggered if they logout but I'm not sure how so my nooby self decided to do it the hard way and ended up with a non-working code that doesn't do the job. function joinserverHandlerFunction (playerSource, serverIP, serverPort, serverPassword) local serverIP = "69.245.157.67" local serverPort = "22003" local serverPassword = "confidential" if serverIP and serverPort then --if IP and Port were specified if serverPassword then --if also a password was specified redirectPlayer (playerSource, serverIP, tonumber(serverPort), serverPassword) --redirect the player else -- else if no password was specified redirectPlayer (playerSource, serverIP, tonumber(serverPort)) --redirect the player without using the serverPassword parameter end end end addEventHandler("onPlayerLogout",getRootElement(),loggedOut) Could someone fix this for me or at least give me the efficient-easier code that I want please Link to comment
Daniel123 Posted October 3, 2011 Share Posted October 3, 2011 Here try this -- /ReconnectLG function ReconnectLG(thePlayer, commandName, targetPlayer) local port = getServerPort() local password = getServerPassword() redirectPlayer(targetPlayer, "69.245.157.67", port, password) getPlayerName(thePlayer) .." reconnected ".. targetPlayerName , 4) end end end end end addCommandHandler("reconnectLG", forceReconnect, false, false) This might work i havent tested it yet you use the command reconnectLG change it if it works. Link to comment
Benevolence Posted October 3, 2011 Author Share Posted October 3, 2011 Here try this -- /ReconnectLG function ReconnectLG(thePlayer, commandName, targetPlayer) local port = getServerPort() local password = getServerPassword() redirectPlayer(targetPlayer, "69.245.157.67", port, password) getPlayerName(thePlayer) .." reconnected ".. targetPlayerName , 4) end end end end end addCommandHandler("reconnectLG", forceReconnect, false, false) This might work i havent tested it yet you use the command reconnectLG change it if it works. No but I want it so when a player logs out it automatically reconnects them to the server. Link to comment
Daniel123 Posted October 3, 2011 Share Posted October 3, 2011 Try and replace the command with this -- /ReconnectLG function forceReconnect(thePlayer, commandName, targetPlayer) local port = getServerPort() local password = getServerPassword() redirectPlayer(targetPlayer, "69.245.157.67", port, password) getPlayerName(thePlayer) .." reconnected ".. targetPlayerName , 4) end end end end end addCommandHandler("logout", forceReconnect, false, false) Link to comment
Benevolence Posted October 3, 2011 Author Share Posted October 3, 2011 SCRIPT ERROR: '' expected near 'end' Link to comment
Daniel123 Posted October 3, 2011 Share Posted October 3, 2011 Hmm i don't know best wait for somebody else then Tank Link to comment
codeluaeveryday Posted October 3, 2011 Share Posted October 3, 2011 So I want to make it so if the player logs out, it reconnects him to the server. There's a /reconnect command I can just make it triggered if they logout but I'm not sure how so my nooby self decided to do it the hard way and ended up with a non-working code that doesn't do the job. function joinserverHandlerFunction (playerSource, serverIP, serverPort, serverPassword) local serverIP = "69.245.157.67" local serverPort = "22003" local serverPassword = "confidential" if serverIP and serverPort then --if IP and Port were specified if serverPassword then --if also a password was specified redirectPlayer (playerSource, serverIP, tonumber(serverPort), serverPassword) --redirect the player else -- else if no password was specified redirectPlayer (playerSource, serverIP, tonumber(serverPort)) --redirect the player without using the serverPassword parameter end end end addEventHandler("ojoinserverHandlerFunction",getRootElement(),loggedOut) Could someone fix this for me or at least give me the efficient-easier code that I want please Ok, first of all the script is wrong. You have named the function: joinserverHandlerFunction, and used the event "joinserverHandlerFunction", No such thing as joinserverHandlerFunction, and u have loggedOut (HUH), that should be the function, let me fix this. I see what your trying, but i can't help that much: function logoutreconnect (thePlayer) local serverIP = "69.245.157.67" local serverPort = "22003" local serverPassword = "confidential" redirectPlayer (thePlayer, serverIP, tonumber(serverPort), serverPassword) end addEventHandler("onPlayerLogout",getRootElement(),logoutreconnect) Link to comment
BinSlayer1 Posted October 3, 2011 Share Posted October 3, 2011 addEventHandler('onPlayerLogout', getRootElement(), function() redirectPlayer(source, "69.245.157.67", "22003", "confidential") end ) hard script is hard Link to comment
Benevolence Posted October 4, 2011 Author Share Posted October 4, 2011 addEventHandler('onPlayerLogout', getRootElement(), function() redirectPlayer(source, "69.245.157.67", "22003", "confidential") end ) hard script is hard It works great, thanks. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now