Lipee Lima Posted May 22, 2022 Share 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 Link to comment
Pedrow Posted July 22, 2022 Share Posted July 22, 2022 E aí, @Lipee Lima, para organizar uma tabela em uma certa ordem, você pode utilizar a função table.sort. Link to comment
Other Languages Moderators Lord Henry Posted July 23, 2022 Other Languages Moderators Share Posted July 23, 2022 @Lipee Lima copiou errado o código. Tente novamente: 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