Jump to content

scrollpane


Desaster

Recommended Posts

well first error was that when I sorted the table it order me the kills from the lowest value to the highest (0, 1, 2) and I need from the highest to the lowest ( 500, 200, 10, 1, 0) also it shows me for every gang the number 0 then for every gang the number 1 ( that numbers are the kills of just one gang )

well what I made is a bit shitty here is my code tell me what I've made false

  
function createKills(scrollPane, theTable) 
    local stuffCount = 1 
    local kill = {} 
    local test = {} 
    local test1 = {} 
    for k,v in ipairs(theTable) do 
    table.insert(test, v[ "kills" ]) 
    table.insert(test1, v[ "name" ]) 
    end  
    table.sort(test) 
    for k, v in ipairs(test) do 
      for i, h in ipairs(test1) do 
        table.insert(kill, guiCreateLabel(0, stuffCount*19, 287, 17, tostring ( v ).." - "..tostring( h ), false, scrollPane)) 
        stuffCount = stuffCount + 1 
        for k, v in ipairs(getElementsByType("gui-label", resourceRoot)) do 
            if (getElementParent(v) == scrollPane) then 
                guiSetFont(v, "default-bold-small") 
            end 
        end 
      end 
    end 
    return kill 
end 

ps : TheTable, and scrollPane are defined

Link to comment
function createKills ( scrollPane, theTable ) 
    local stuffCount = 1 
    local kill = { } 
    table.sort ( 
        theTable, 
        function ( a, b ) 
            return ( tonumber ( a.kills ) or 0 ) > ( tonumber ( b.kills ) or 0 ) 
        end 
    ) 
  
    for _, v in ipairs ( theTable ) do 
        local label = guiCreateLabel ( 0, ( stuffCount * 19 ), 287, 17, tostring ( v [ "name" ] ) .." - ".. tostring ( v [ "kills" ] ), false, scrollPane ) 
        guiSetFont ( label, "default-bold-small" ) 
        table.insert ( kill, label ) 
        stuffCount = ( stuffCount + 1 ) 
    end 
  
    return kill 
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...