Jump to content

PAINEL DE TOP RANKING


lc171

Recommended Posts

preciso de ajuda no painel de top rank , preciso adcionar uma coluna de numeração tambem colocar  em ordem (da quantidade maior de kill para menor quantidade).

client side

scoreWindow = guiCreateWindow (0.3, 0.2, 0.4, 0.6, "Ranking Kills/Death", true) scoreGrid = guiCreateGridList (0, 0.05, 1, 0.85, true, scoreWindow) guiWindowSetSizable (scoreWindow, false) guiGridListAddColumn (scoreGrid, "Account", 0.45) guiGridListAddColumn (scoreGrid, "Kills", 0.13) guiGridListAddColumn (scoreGrid, "Deaths", 0.13) guiGridListAddColumn (scoreGrid, "Ratio", 0.18) closeGrid = guiCreateButton (0.2, 0.91, 0.6, 0.09, "Fechar Painel", true, scoreWindow) guiSetVisible (scoreWindow, false) function scoreInfo (accounts, kills, deaths, ratio) guiSetVisible (scoreWindow, true) guiSetVisible (closeGrid, true) showCursor (true) if accounts then for i, v in ipairs (accounts) do guiGridListAddRow (scoreGrid, accounts, kills, deaths, math.round (tonumber(ratio), 2, "floor")) end end end addEvent ("showRank", true) addEventHandler ("showRank", getRootElement(), scoreInfo) function clickOptions (button, state, absoluteX, absoluteY) if button == "left" then if source == closeGrid then guiSetVisible (scoreWindow, false) showCursor (false) guiGridListClear (scoreGrid) end end end addEventHandler ("onClientGUIClick", getRootElement(), clickOptions) function math.round (number, decimals, method) decimals = decimals or 0 local factor = 10 ^ decimals if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor else return tonumber(("%."..decimals.."f"):format(number)) end end function sendScores () if not guiGetVisible (scoreWindow) then triggerServerEvent ("getRank", localPlayer) end end bindKey("F9","down",sendScores)

server side

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)) if not getAccountData (data, "kills") then table.insert (killsTable, "0") kill = 0 else table.insert (killsTable, tostring (getAccountData (data, "kills"))) kill = tonumber (getAccountData (data, "kills")) end if not getAccountData (data, "deaths") then table.insert (deathsTable, "0") death = 0 else table.insert (deathsTable, tostring (getAccountData (data, "deaths"))) death = tonumber (getAccountData (data, "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) function salvaKills (ammo, killer, weapon, bodypart, stealth) if not isGuestAccount (getPlayerAccount(source)) then local deaths = getAccountData (getPlayerAccount(source), "deaths") if deaths then setAccountData (getPlayerAccount(source), "deaths", deaths + 1) else setAccountData (getPlayerAccount(source), "deaths", 1) end end if killer and killer ~= source then if getElementType (killer) == "player" then if not isGuestAccount (getPlayerAccount(killer)) then local kills = getAccountData (getPlayerAccount(killer), "kills") if kills then setAccountData (getPlayerAccount(killer), "kills", kills + 1) else setAccountData (getPlayerAccount(killer), "kills", 1) end end elseif getElementType (killer) == "vehicle" then killer = getVehicleController (killer) if killer then if not isGuestAccount (getPlayerAccount(killer)) then local kills = getAccountData (getPlayerAccount(killer), "kills") if kills then setAccountData (getPlayerAccount(killer), "kills", kills + 1) else setAccountData (getPlayerAccount(killer), "kills", 1) end end end end end end addEventHandler ("onPlayerWasted", getRootElement(), salvaKills)''


 

Link to comment
  • Tut locked this topic
  • Administrators

Welcome to the forums @lc171

As this forum section is English, all content should be aimed towards that audience.
If you want to post in the Portuguese language, please use the correct forum sections: https://forum.multitheftauto.com/forum/127-programação-em-lua/

As a side note, instead of pasting code straight into your post, please use the code block function that can be accessed from the Post Editor <> button in the top row!

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...