Memory Posted October 25, 2012 Share Posted October 25, 2012 Hello, How can, from this code, make command - /rank and outputChatBox("Your position "..position, root, 255, 255, 255 ) Sort code function sortAccounts( ) local rowdata = { } for _, account in pairs( getAccounts( ) ) do rowdata[ #rowdata + 1 ] = { account = getAccountName( account ), points = getAccountData( account,"Points" ) } end table.sort( rowdata, function ( a, b ) return ( tonumber( a.points ) or 0 ) > ( tonumber( b.points ) or 0 ) end ) return rowdata end Link to comment
Guest Guest4401 Posted October 25, 2012 Share Posted October 25, 2012 addCommandHandler("rank", function(p) local accs = getAccounts() local acc = getPlayerAccount(p) local position table.sort(accs, function(a,b) return (getAccountData(a,"Points") or 0) > (getAccountData(b,"Points") or 0) end ) if not isGuestAccount(acc) then for i,v in ipairs(accs) do if v == acc then position = i break end end if position then outputChatBox("Your rank is "..position,p) else outputChatBox("You are rankless",p) end else outputChatBox("You forgot to login",p) end 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