local sx,sy = guiGetScreenSize() local resStat = false local serverStats = nil local serverColumns, serverRows = {}, {} local columns local rows function isAllowed() return true end local resourcesConvert = { ['pAttach'] = 'Attachments', ['sqh_custom'] = 'Characters', ['nc_pedagio'] = 'IntegrityGuard', ['nc_interface'] = 'UserInterface', ['nc_newRadar'] = 'RadarMap', ['nc_voice'] = 'Voip', ['nc_animations'] = 'PedAnimations' } addCommandHandler("stat", function() if isAllowed() then resStat = not resStat if resStat then sortTables() TimerC = setTimer(function() sortTables() end, 500, 0) addEventHandler("onClientRender", root, resStatRender) if (getElementData(localPlayer, 'staff:point') or getElementData(localPlayer, 'ID') <= 10) then iprint("getServerStat") triggerServerEvent("getServerStat", resourceRoot) end else if isTimer(TimerC) then killTimer(TimerC) end removeEventHandler("onClientRender", root, resStatRender) serverStats = nil serverColumns, serverRows = {}, {} triggerServerEvent("destroyServerStat", resourceRoot) end end end) function sortTables() columns, rows = getPerformanceStats("Lua timing") table.sort(rows, function(a, b) if a[2] and b[2] then local percentA = a[2]:gsub("%%", "") or '0' local percentB = b[2]:gsub("%%", "") or '0' percentA = tonumber(percentA or 0) or 0 percentB = tonumber(percentB or 0) or 0 if percentA and percentB then return percentA > percentB end end end) end addEvent("receiveServerStat", true) addEventHandler("receiveServerStat", resourceRoot, function(stat1,stat2) serverStats = true serverColumns, serverRows = stat1,stat2 table.sort(serverRows, function(a, b) if a[2] and b[2] then local percentA = a[2]:gsub("%%", "") or '0' local percentB = b[2]:gsub("%%", "") or '0' percentA = tonumber(percentA or 0) or 0 percentB = tonumber(percentB or 0) or 0 if percentA and percentB then return percentA > percentB end end end) end) local ressourceAtual = getResourceName(getThisResource()) function resStatRender() local x = sx - 300 if (#serverRows == 0) then x = sx - 140 end local height = (15 * #rows) local y = sy / 2 - height / 2 if (#serverRows == 0) then dxDrawText("Client",sx-75,y-20,sx-75,y-20,tocolor(255,255,255,255),1.2,"default_bold","center") else dxDrawText("Client",sx-235,y-20,sx-235,y-20,tocolor(255,255,255,255),1.2,"default_bold","center") end y = y + 5 for i = 1, #rows do local row = rows[i] if row then local resName = row[1]:sub(0,15) resName = resourcesConvert[resName] or resName local text = resName:sub(0,15)..": "..row[2] local percentNumber = row[2]:gsub("%%", "") local percent = tonumber(percentNumber) if not text:find(ressourceAtual) and not text:find('nc_core') then dxDrawText(text,x+1,y+1,150,15, tocolor(0,0,0,255),1,"default_bold") dxDrawText(text,x,y,150,15, type(percent) == 'number' and (percent <= 2 and tocolor(255,255,255,180) or percent >= 3 and tocolor(255, 157, 0, 245) or percent >= 6 and tocolor(171, 38, 49, 245) or percent >= 10 and tocolor(255, 0, 0, 240)) or tocolor(255, 255, 255, 245),1,"default_bold") y = y + 15 end end end if (getElementData(localPlayer, 'staff:point') or getElementData(localPlayer, 'ID') <= 5) then if #serverRows ~= 0 then local x = sx - 140 local height = (15 * #serverRows) local y = sy / 2 - height / 2 dxDrawText("Server",sx-75,y-20,sx-75,y-20,tocolor(255,255,255,255),1.2,"default_bold","center") y = y + 5 for i = 1, #serverRows do local row = serverRows[i] if row then local resName = row[1]:sub(0,15) resName = resourcesConvert[resName] or resName local text = resName:sub(0,15)..": "..row[2] local percentNumber = row[2]:gsub("%%", "") local percent = tonumber(percentNumber) if not text:find(ressourceAtual) and not text:find('nc_core') then dxDrawText(text, x+1, y+1, 150, 15,tocolor(0,0,0,255), 1, "default_bold") dxDrawText(text, x, y, 150, 15, type(percent) == 'number' and (percent <= 2 and tocolor(255,255,255,180) or percent >= 3 and tocolor(255, 157, 0, 245) or percent >= 6 and tocolor(171, 38, 49, 245) or percent >= 10 and tocolor(255, 0, 0, 240)) or tocolor(255, 255, 255, 245), 1, "default_bold") y = y + 15 end end end end end end