Jump to content

Position of points


Memory

Recommended Posts

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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