test

mail@pastecode.io avatar
unknown
lua
2 years ago
2.2 kB
5
Indexable
Never
addEvent("top:ranks3", true)
addEventHandler("top:ranks3", root,
function(T)
    if type(T) == "table" then
        local rank = 0
        for index, value in spairs(T,function(t,a,b) return tonumber(t[a]['kills']) > tonumber(t[b]['kills']) end) do
        rank = rank + 1
        guiGridListClear(GUIEditor.gridlist[1]);
        local Row = guiGridListAddRow(GUIEditor.gridlist[1]);
        local kd = value["deaths"] == 0. and value["kills"] or tonumber(value["kills"])/ tonumber(value["deaths"])
        local isOnline = (value["status"] ~= "Online")
            guiGridListSetItemText(GUIEditor.gridlist[1], Row, 1, ""..rank.."-", false, false)
            guiGridListSetItemText(GUIEditor.gridlist[1], Row, 2, value["name"], false, false)
            guiGridListSetItemText(GUIEditor.gridlist[1], Row, 3,  value["acc"], false, false)
            guiGridListSetItemText(GUIEditor.gridlist[1], Row, 4, tonumber(value["kills"]), false, false)
            guiGridListSetItemText(GUIEditor.gridlist[1], Row, 5, tonumber(value["deaths"]), false, false)
            guiGridListSetItemText(GUIEditor.gridlist[1], Row, 6, kd, false, false)
            guiGridListSetItemText(GUIEditor.gridlist[1], Row, 7, tonumber(value["level"]), false, false)
            guiGridListSetItemText(GUIEditor.gridlist[1], Row, 8, value["status"], false, false)
            guiGridListSetItemColor(GUIEditor.gridlist[1], Row,1,255,0,0,255)
            guiGridListSetItemColor(GUIEditor.gridlist[1], Row,2,255,0,255,255)
            guiGridListSetItemColor(GUIEditor.gridlist[1], Row,3,255,0,255,255)
            guiGridListSetItemColor(GUIEditor.gridlist[1], Row,4,255,0,255,255)
            guiGridListSetItemColor(GUIEditor.gridlist[1], Row,5,255,100,0,255)
            guiGridListSetItemColor(GUIEditor.gridlist[1], Row,6,255,0,255,255)
            guiGridListSetItemColor(GUIEditor.gridlist[1], Row,7,255,0,255,255)
            --guiGridListSetItemColor(GUIEditor.gridlist[1], Row,8,0,255,0,255)
            guiGridListSetItemColor(GUIEditor.gridlist[1], Row, 8, isOnline and 255 or 0, isOnline and 0 or 255, 0)

        end
    end
end);