Lipee Lima Posted May 22, 2022 Posted May 22, 2022 (edited) Opa, gostaria de saber como faço para que quando o rank for chamado ele organize em ordem por Kills. Tipo 1,2,3 e etc... function recebeKills () local data = getAccounts () local accTable = {} local killsTable = {} local deathsTable = {} local killDeath = {} local kill = 0 local death = 0 if not data[1] then triggerClientEvent (client, "showScores", client) return end for i, acc in ipairs (data) do table.insert (accTable, getAccountName (data[i])) if not getAccountData (data[i], "kills") then table.insert (killsTable, "0") kill = 0 else table.insert (killsTable, tostring (getAccountData (data[i], "kills"))) kill = tonumber (getAccountData (data[i], "kills")) end if not getAccountData (data[i], "deaths") then table.insert (deathsTable, "0") death = 0 else table.insert (deathsTable, tostring (getAccountData (data[i], "deaths"))) death = tonumber (getAccountData (data[i], "deaths")) end if death == 0 and kill == 0 then table.insert (killDeath, 0) else table.insert (killDeath, kill / death) end end triggerClientEvent (client, "showRank", client, accTable, killsTable, deathsTable, killDeath) end addEvent ("getRank", true) addEventHandler ("getRank", getRootElement(), recebeKills) Edited May 22, 2022 by Lipee Lima
Pedrow Posted July 22, 2022 Posted July 22, 2022 E aí, @Lipee Lima, para organizar uma tabela em uma certa ordem, você pode utilizar a função table.sort.
Moderators Lord Henry Posted July 23, 2022 Moderators Posted July 23, 2022 @Lipee Lima copiou errado o código. Tente novamente: Eu te ajudei ou achou meu comentário útil? Não esqueça de deixar um Thanks! Minhas contribuições para a comunidade: LordHenry - MTA Wiki Profile Inscreva-se no meu canal do YouTube: Lord Henry - Entertainment Discord Oficial do MTA: https://mtasa.com/discord Blacklist e Whitelist de Scripters: Planilha Por favor, não me envie mensagens privadas solicitando suporte. Crie um tópico no fórum em vez disso.
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