Giovany Mito Posted July 30, 2019 Posted July 30, 2019 Olá, Estou com problemas com o sistema de id player. No meu comando eu uso para puxar um player usando o id dele e não o nick, mais ai que esta o problema o player nao tem um id fixo. no scoreboard tem um id fixo mais quando puxo não tem. no score board marca assim exemplo : ID 1 Giio ID 2 Fulano se o ID 1 Desloga automatico o 2 fulano vira o id 1 mais você não ve, no scoreboard continua ID 2, oque seria ??
Other Languages Moderators Lord Henry Posted July 30, 2019 Other Languages Moderators Posted July 30, 2019 Sem código fica difícil adivinhar. Mas já vou logo adiantando que vc usa o getAccountID.
DNL291 Posted July 30, 2019 Posted July 30, 2019 Se não tiver funcionando corretamente, baixe um sistema de ID funcional ou apenas use a função mencionada acima.
Giovany Mito Posted July 31, 2019 Author Posted July 31, 2019 21 hours ago, Lord Henry said: Sem código fica difícil adivinhar. Mas já vou logo adiantando que vc usa o getAccountID. 19 hours ago, DNL291 said: Se não tiver funcionando corretamente, baixe um sistema de ID funcional ou apenas use a função mencionada acima. function getPlayer(player, cmd, id) if tonumber(id) then local mx, my, mz = getElementPosition(player) local player2 = getPlayerFromID ( tonumber(id) ) if not player2 or not isElement(player2) then return outputChatBox( "Player Offline", player ) end local trplayername = getPlayerName(player):gsub("#%x%x%x%x%x%x","") local rand = math.random(1, 5) setElementPosition(player2, mx+rand, my+rand, mz + 1) for i, p in ipairs(getElementsByType("player")) do local xp, yp, zp = getElementPosition ( p ) if getDistanceBetweenPoints3D ( mx, my, mz, xp, yp, zp ) <= 50 then outputChatBox ( "#c9c9c9[#1a6cefFW-COMANDO#c9c9c9]O #1a6cef".. trplayername .."#c9c9c9 Puxou o #1a6cef".. tostring(id), p, 255, 0, 0, true ); end end end end addCommandHandler("tr", getPlayer) Esse é o comando onde uso para puxar o player usando o id em vez do nome function getIDFromPlayer(player) if player then local theid players = getElementsByType("player") for id,p in ipairs(players) do if player == p then theid = i end end return theid else return false end end function getPlayerFromID(theID) if theID then theID = tonumber(theID) local theplayer players = getElementsByType("player") for id,p in ipairs(players) do if theID == id then theplayer = p end end return theplayer else return false end end Esse é para pegar o id do player
Other Languages Moderators Lord Henry Posted July 31, 2019 Other Languages Moderators Posted July 31, 2019 Essa sua função getPlayerFromID está errada. Não tem nada a ver com ID dos jogadores, apenas com o índice daquele loop. Dai é óbvio que não vai retornar o mesmo ID pro mesmo jogador. function getPlayerFromID (theID) if (tonumber (theID)) then theID = tonumber (theID) local players = getElementsByType ("player") for id, p in ipairs (players) do local accID = getAccountID (getPlayerAccount (p)) if (theID == accID) then return p end end return false else return false end end 1
Giovany Mito Posted August 1, 2019 Author Posted August 1, 2019 8 hours ago, Lord Henry said: Essa sua função getPlayerFromID está errada. Não tem nada a ver com ID dos jogadores, apenas com o índice daquele loop. Dai é óbvio que não vai retornar o mesmo ID pro mesmo jogador. function getPlayerFromID (theID) if (tonumber (theID)) then theID = tonumber (theID) local players = getElementsByType ("player") for id, p in ipairs (players) do local accID = getAccountID (getPlayerAccount (p)) if (theID == accID) then return p end end return false else return false end end Entendi, vou tentar testar com alguem jaja
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