Jump to content

Search the Community

Showing results for tags 'sort table'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Multi Theft Auto: San Andreas 1.x
    • Support for MTA:SA 1.x
    • User Guides
    • Open Source Contributors
    • Suggestions
    • [Read-Only] Ban appeals
  • General MTA
    • News
    • Media
    • Site/Forum/Discord/Mantis/Wiki related
    • MTA Chat
    • Other languages
  • MTA Community
    • Scripting
    • Maps
    • Resources
    • Other Creations & GTA modding
    • Competitive gameplay
    • Servers
  • Other
    • General
    • Multi Theft Auto 0.5r2
    • Third party GTA mods
  • Archive
    • Archived Items
    • Trash

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Gang


Location


Occupation


Interests

Found 1 result

  1. Hi, I need to find a way of sorting two tables with the same order: "kills" and "player names" tables, I manage to sort kills table by value but I don't know how to sort the player names table with the same order than kills table. Here is my code: --client side local screenW, screenH = guiGetScreenSize() --I use the colshapes to "simulate" players datas. col1 = createColSphere(0,0,0, 1) col2 = createColSphere(0,0,0, 1) col3 = createColSphere(0,0,0, 1) col4 = createColSphere(0,0,0, 1) col5 = createColSphere(0,0,0, 1) col6 = createColSphere(0,0,0, 1) col7 = createColSphere(0,0,0, 1) col8 = createColSphere(0,0,0, 1) col9 = createColSphere(0,0,0, 1) col10 = createColSphere(0,0,0, 1) col11 = createColSphere(0,0,0, 1) setElementData(col1, "kills.actual", 5) setElementData(col2, "kills.actual", 10) setElementData(col3, "kills.actual", 16) setElementData(col4, "kills.actual", 2) setElementData(col5, "kills.actual", 1) setElementData(col6, "kills.actual", 50) setElementData(col7, "kills.actual", 21) setElementData(col8, "kills.actual", 21) setElementData(col9, "kills.actual", 12) setElementData(col10, "kills.actual", 9) setElementData(col11, "kills.actual", 106) setElementData(col1, "kills.names", "test1") setElementData(col2, "kills.names", "test2") setElementData(col3, "kills.names", "test3") setElementData(col4, "kills.names", "test4") setElementData(col5, "kills.names", "test9") setElementData(col6, "kills.names", "test5") setElementData(col7, "kills.names", "test6") setElementData(col8, "kills.names", "#ff0000Akai") setElementData(col9, "kills.names", "#00ff00Green") setElementData(col10, "kills.names", "#0000ffBlue") setElementData(col11, "kills.names", "#ff00ff:O knows") function renderTabla() dxDrawImage(screenW - 318 - 10, (screenH - 198) / 2, 318, 198, "bgr.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawText("Kills on this round", screenW - 318 - 10, (screenH - 188) / 2, (screenW - 318 - 10) + 318, ( (screenH - 188) / 2) + 188, tocolor(255, 255, 255, 255), 0.66, "bankgothic", "center", "top", true, true, true, true, false) --sort the kills by hight value table.sort(tableKills, function (a,b) return tonumber(a) > tonumber (b) end ) if tableKills then for i=1,10 do posY = ((screenH-394)*0.81+(i*screenH*0.02)) dxDrawText(i.."- "..tableNames[i], (screenW - 308 - 10), posY, (screenW - 308 - 10) + 308, ( (screenH - 164) / 2) + 164, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", true, true, true, true, false) dxDrawText("Kills: "..tableKills[i], (screenW - 150 - 10), posY, (screenW - 308 - 10) + 150, ( (screenH - 164) / 2) + 164, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", true, true, true, true, false) end end end function testCols () tableKills = {} tableNames = {} --just pretending loop through players tablaCol = getElementsByType("colshape") for i=1,#getElementsByType("colshape") do colEle = getElementData(tablaCol[i], "kills.actual") colNom = getElementData(tablaCol[i], "kills.names") table.insert(tableKills, i, colEle) table.insert(tableNames, i, colNom) end setTimer(function() addEventHandler("onClientRender", getRootElement(), renderTabla) end, 3000, 1) end --for testing bindKey("5", "down", testCols) Please help!
×
×
  • Create New...