--- Client side
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);
addEvent("setOnline", true)
addEventHandler("setOnline", root, function(acc)
if (acc) then
local id = getGridListRowIndexFromText(GUIEditor.gridlist[1], acc)
guiGridListSetItemText(GUIEditor.gridlist[1], id, 8, "Online")
guiGridListSetItemColor(GUIEditor.gridlist[1], id, 8, 0, 255, 0)
end
end
end)
addEvent("setOffline", true)
addEventHandler("setOffline", root, function(acc)
if (acc) then
local id = getGridListRowIndexFromText(GUIEditor.gridlist[1], acc)
guiGridListSetItemText(GUIEditor.gridlist[1], id, 8, "Offline")
guiGridListSetItemColor(GUIEditor.gridlist[1], id, 8, 255, 0, 0)
end
end
end)
function getGridListRowIndexFromText(gridList, text, column)
for i=0, guiGridListGetRowCount(gridList)-1 do
if (guiGridListGetItemText(gridList, i, column) == text) then
return i
end
end
return false
end