freudo Posted June 7, 2015 Share Posted June 7, 2015 Hey I want ranking players for experience. Example: Scoreboard exam: playername experience rank barikat 25000 1. skyturk 12055 2. Can you help me? Example codes: Checking experience function getPlayerExperiencet(thePlayer) local handler = connection if (isElement(thePlayer) and getElementType(thePlayer) == "player") then account = getPlayerAccount(thePlayer) else account = thePlayer end if (not account or isGuestAccount(account)) then return false end local accountName = getAccountName(account) local query = dbQuery( handler, "SELECT experiencet FROM `levels` WHERE accountName='".. tostring(accountName) .."'") local result, numrows, errmsg = dbPoll( query, -1 ) if (result) then return tonumber(result[1]["experiencet"]) end end Link to comment
xXMADEXx Posted June 8, 2015 Share Posted June 8, 2015 Use the export from scoreboard 'scoreboardAddColumn ' (eg. exports.scoreboard:scoreboardAddColumn (args....)) and then you can use setElementData to set the players experience and rank. Link to comment
freudo Posted June 8, 2015 Author Share Posted June 8, 2015 I have only account rank system How to I change to SQL function getAllRankSB() local tableOrder = { } for i, v in ipairs ( getAccounts ( ) ) do table.insert ( tableOrder, { name = getAccountName(v), data = getAccountData ( v, "experiencet" ) } ) end table.sort ( tableOrder, function ( a, b ) return ( tonumber ( a.data ) or 0 ) > ( tonumber ( b.data ) or 0 ) end ) for i,player in pairs(getElementsByType("player")) do if not (isGuestAccount(getPlayerAccount(player))) then for i=1,#tableOrder do if tableOrder[i].name == getAccountName(getPlayerAccount(player)) then setElementData(player,"Sıra",i) end end end end outputDebugString("Updating rank for all player") end setTimer(function() getAllRankSB() end,300000,0) 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