Jacobob14 Posted March 27, 2015 Share Posted March 27, 2015 hi am doing a scoreboard everything works fine but would like to know how I can sort players for his team as in the dxscoreboard of the comunity ServerPlayers = {} cache = 1 function scoreboarddx() dxDrawRectangle(x1*250, y1*300, x1*500, y1*500, tocolor(80, 80, 80, 160), false) dxDrawRectangle(x1*250, y1*250, x1*500, y1*50, tocolor(40, 40, 40, 240), false) dxDrawText("Name", x1*320, (204/768)*sY, (599/1366)*sX, (275/768)*sY, tocolor(255, 255, 255, 255), 1.20, "clear", "left", "center", false, false, false, false, false) number = 0 for i = cache, cache + 13 do if i <= #ServerPlayers then if ServerPlayers then if ServerPlayers[i] ~= nil and ServerPlayers[i] ~= false then local r, g, b if getElementType(ServerPlayers[i]) == "player" then r, g, b = getPlayerNametagColor ( ServerPlayers[i] ) else r, g, b = 255, 255, 255 end local nick = getPlayerName(ServerPlayers[i]) or getElementData(ServerPlayers[i],"name") dxDrawText(nick , x1*320, ((284 + number)/768)*sY, x1*438, (275/768)*sY, tocolor(r, g, b, 255), 1.20, "clear", "left", "center", false, false, false, true, false) dxDrawText(getElementData ( ServerPlayers[i], "level" ) or 0, (726/1366)*sX, ((284 + number)/768)*sY, (968/1366)*sX, (275/768)*sY, tocolor(255, 255, 255, 255), 1.20, "clear", "center", "center", false, false, false, false, false) number = number + 40 end end end end end function Players () local players = getElementsByType ( "player" ) ServerPlayers = nil ServerPlayers = {} for theKey,thePlayer in ipairs(players) do table.insert (ServerPlayers, thePlayer) end end Link to comment
JR10 Posted March 27, 2015 Share Posted March 27, 2015 You can easily sort players with something like this: table.sort(tab, function(a, b) return getCountry(a) < getCountry(b) end) 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