Desaster Posted December 3, 2013 Share Posted December 3, 2013 heyo I want to create a scroll pane filled by players on the screen how to fill it ? Link to comment
Castillo Posted December 3, 2013 Share Posted December 3, 2013 guiCreateScrollPane getElementsByType isElementOnScreen guiCreateLabel Link to comment
Desaster Posted December 3, 2013 Author Share Posted December 3, 2013 hmmm how to remove that scrollpane from the scroll bar ? Link to comment
Desaster Posted December 3, 2013 Author Share Posted December 3, 2013 so I have in my scroll pane gangs and gang kills and I want that the gang with the most kills is the first one in the scroll pane how to do that ? Link to comment
Castillo Posted December 3, 2013 Share Posted December 3, 2013 You must sort it. You can use table.sort. Link to comment
Desaster Posted December 3, 2013 Author Share Posted December 3, 2013 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
Castillo Posted December 4, 2013 Share Posted December 4, 2013 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
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