freudo Posted June 13, 2015 Share Posted June 13, 2015 Not working code: function redirectPlayer(thePlayer, commandName,targetPlayer, serverIP, serverPort) local playername = getPlayerName(thePlayer) if playername and targetPlayer and serverIP and serverPort then local targetPlayer = findPlayerByName(targetPlayer) redirectPlayer(targetPlayer,serverIP,tonumber(serverPort)) else outputChatBox("Error",source,255,0,0,true) end end addCommandHandler("rd",redirectPlayer) function findPlayerByName(name) local player = getPlayerFromName(name) if player then return player end for i, player in ipairs(getElementsByType("player")) do if string.find(string.gsub(getPlayerName(player):lower(),"#%x%x%x%x%x%x", ""), name:lower(), 1, true) then return player end end return false end Link to comment
HUNGRY:3 Posted June 13, 2015 Share Posted June 13, 2015 function redirectPlayer(thePlayer, commandName,targetPlayer, serverIP, serverPort) local playername = getPlayerName(thePlayer) if playername and targetPlayer and serverIP and serverPort then local targetPlayer = getPlayerFromNick(targetPlayer) redirectPlayer(targetPlayer,serverIP,tonumber(serverPort)) else outputChatBox("Error",source,255,0,0,true) end end addCommandHandler("rd",redirectPlayer) function findPlayerByName(name) local player = getPlayerFromName(name) if player then return player end for i, player in ipairs(getElementsByType("player")) do if string.find(string.gsub(getPlayerName(player):lower(),"#%x%x%x%x%x%x", ""), name:lower(), 1, true) then return player end end return false end not tested Link to comment
freudo Posted June 13, 2015 Author Share Posted June 13, 2015 Same Command this ? /rd playerName 0.00.000.00 00000 Link to comment
freudo Posted June 13, 2015 Author Share Posted June 13, 2015 No error, just chatbox saying "Error" Link to comment
Walid Posted June 13, 2015 Share Posted June 13, 2015 No error, just chatbox saying "Error" Try this it should work function redirectPlayer(thePlayer, commandName,targetPlayer, serverIP, serverPort) if targetPlayer and serverIP and serverPort then local target = findPlayerByName(targetPlayer) if (not isElement(target)) then outputChatBox("This player does no longer exist!", thePlayer, 255, 0, 0) return end redirectPlayer(target,serverIP,tonumber(serverPort)) else outputChatBox("something missing please try again!",thePlayer,255,0,0,true) end end addCommandHandler("rd",redirectPlayer) function findPlayerByName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end Link to comment
Tomas Posted June 13, 2015 Share Posted June 13, 2015 _redirectPlayer = redirectPlayer function redirectPlayer(thePlayer, commandName,targetPlayer, serverIP, serverPort) if targetPlayer and serverIP and serverPort then local target = findPlayerByName(targetPlayer) if (not isElement(target)) then outputChatBox("This player does no longer exist!", thePlayer, 255, 0, 0) return end _redirectPlayer(target,serverIP,tonumber(serverPort)) else outputChatBox("something missing please try again!",thePlayer,255,0,0,true) end end addCommandHandler("rd",redirectPlayer) function findPlayerByName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end Link to comment
TAPL Posted June 13, 2015 Share Posted June 13, 2015 _redirectPlayer = redirectPlayer function redirectPlayer(thePlayer, commandName,targetPlayer, serverIP, serverPort) if targetPlayer and serverIP and serverPort then local target = findPlayerByName(targetPlayer) if (not isElement(target)) then outputChatBox("This player does no longer exist!", thePlayer, 255, 0, 0) return end _redirectPlayer(target,serverIP,tonumber(serverPort)) else outputChatBox("something missing please try again!",thePlayer,255,0,0,true) end end addCommandHandler("rd",redirectPlayer) function findPlayerByName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end No need for this, just use a different function name or use anonymous function. 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