Jump to content

Hi all


S3M

Recommended Posts

Hi all.

Is it possible to make a rank bankmoney top 5 that views which player have the most bankmoney on screen?.

See image.

62379d024b591a4ed532815769ca71f2.jpg

Which way on wiki would i be looking?

or are there is already a usable resource for this kind of scoreboard on screen?

Thx.

Link to comment

Try this

function FindReachPlayers( nPlayersCount ) 
    if type( nPlayersCount ) == 'number' then 
        local nStart = 0 
        local pAddPlayer 
        local nIndexRemove = 0 
        local aReturnPlayers = { } 
        local aReachPlayers = { } 
        for _, pPlayer in pairs( getElementsByType 'player' ) do 
            table.insert( aReachPlayers, { [ pPlayer ] = getPlayerMoney( pPlayer ) } ) 
        end 
        for n = 1, nPlayersCount do 
            for nIndex, a in ipairs( aReachPlayers ) do 
                for pPlayer, nMoney in pairs( a ) do 
                    if nStart <= nMoney then 
                        nStart = nMoney 
                        nIndexRemove = nIndex 
                        pAddPlayer = pPlayer 
                    end 
                end 
            end 
            if not aReachPlayers[ nIndexRemove ] then 
                return aReturnPlayers 
            end 
            table.insert( aReturnPlayers, { [ pAddPlayer ] = nStart } ) 
            table.remove( aReachPlayers, nIndexRemove ) 
            nIndexRemove = 0 
            nStart = 0 
        end 
        return aReturnPlayers 
    end 
    return false 
end 

Updated again.

Example of use:

for _, a in ipairs( FindReachPlayers( 3 ) ) do 
    for pPlayer, nMoney in pairs( a ) do 
        outputChatBox( 'Player = ' .. getPlayerName( pPlayer ) .. ' , Money = ' .. nMoney  ) 
    end 
end 

Edited by Guest
Link to comment

Or try this, if u want export bank balance from 50'p bank system:

function FindReachPlayers( nPlayersCount ) 
    if type( nPlayersCount ) == 'number' then 
        local nStart = 0 
        local nIndexRemove = 0 
        local aReturnPlayers = { } 
        local aReachPlayers = { } 
        for _, pPlayer in pairs( getElementsByType 'player' ) do 
            local accountName = getAccountName ( getPlayerAccount ( pPlayer ) ) 
            local bank_money = tonumber( exports.bank:getBankAccountBalance(accountName) ) -- exports.RESOURCE_NAME:FUNCTION( ARGUMENTS ) 
            table.insert( aReachPlayers, { [ pPlayer ] = bank_money } ) 
        end 
        for n = 1, nPlayersCount do 
            for nIndex, a in ipairs( aReachPlayers ) do 
                for pPlayer, nMoney in pairs( a ) do 
                    if nStart < nMoney then 
                        table.insert( aReturnPlayers, { [ pPlayer ] = nMoney } ) 
                        nStart = nMoney 
                        nIndexRemove = #aReturnPlayers 
                    end 
                end 
            end 
            table.remove( aReachPlayers, nIndexRemove ) 
            nIndexRemove = 0 
            nStart = 0 
        end 
        return aReturnPlayers 
    end 
    return false 
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...