function getTableSortedByKills ( )
tSS = {}
tSS_f = {}
for index, value in ipairs(getElementsByType("player")) do
tSS[value] = getElementData(value, "kills"), value
end
for k,v in spairs(tSS, function(t,a,b) return t[b] < t[a] end) do
tSS_f[#tSS_f] = k
end
return tSS_f
end
function spairs(t, order)
local keys = {}
for k in pairs(t) do keys[#keys+1] = k end
if order then
table.sort(keys, function(a,b) return order(t, a, b) end)
else
table.sort(keys)
end
local i = 0
return function()
i = i + 1
if keys[i] then
return keys[i], t[keys[i]]
end
end
end
addEventHandler( "onClientRender", root,
function()
if getKeyState( "tab" ) == false then ploff = 0; return end
if getElementData(getLocalPlayer(),"logedin") then
dxDrawRectangle ( baseX, baseY, width, topsize, tocolor(32,32,32),true,false )
dxDrawText ( serverName, baseX+20, baseY+10, baseX+width, baseY+topsize, tocolor(255,255,255), 0.9, "default-bold","left","top",false,false,true )
dxDrawRectangle ( baseX, baseY+topsize, width, panelsize, tocolor(0,0,0,150),true,false )
dxDrawLine ( baseX, baseY+30, baseX+width, baseY+30, tocolor(100,100,100),0.8,true )
dxDrawLine ( baseX, baseY+30, baseX, baseY+panelsize+topsize, tocolor(100,100,100),0.8,true )
dxDrawLine ( baseX, baseY+panelsize+topsize, baseX+width, baseY+panelsize+topsize, tocolor(100,100,100),0.8,true )
dxDrawLine ( baseX+40, baseY+30, baseX+40, baseY+panelsize+topsize, tocolor(100,100,100),0.8,true )
dxDrawText ( "№", baseX, baseY+60, baseX+40, baseY+topsize-30, tocolor(255,255,255), 1, "default-bold", "center", "center",false,false,true )
local xoff = 60
for i, v in ipairs ( scoreboardColumns ) do
dxDrawLine ( baseX+xoff+v.width, baseY+30, baseX+xoff+v.width, baseY+panelsize+topsize, tocolor(100,100,100),0.8,true )
dxDrawText ( v.name, baseX+xoff, baseY+60, baseX+xoff+v.width, baseY+topsize-30, tocolor(255,255,255), 1, "default-bold", "center", "center",false,false,true )
xoff = xoff+v.width
end
local playersTable = getTableSortedByKills ( )
--local playersTable = { localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer, localPlayer }
dxDrawText ( "Online: "..tostring(#playersTable).."/"..tostring(max_players), baseX+20, baseY+10, baseX+width-20, baseY+topsize, tocolor(255,255,255), 0.9, "default-bold", "right","top",false,false,true )
local maxNum = #playersTable
if maxNum > 25 then
maxNum = 25
end
for i = 1, maxNum do
dxDrawLine ( baseX, baseY+topsize+playersize*i, baseX+width, baseY+topsize+playersize*i, tocolor(100,100,100),0.8,true )
dxDrawText ( i+ploff, baseX, baseY+topsize+playersize*(i-1), baseX+40, baseY+topsize+playersize*i, tocolor(255,255,255), 1, "default-bold", "center", "center",false,false,true )
if playersTable[i+ploff] == localPlayer then
dxDrawRectangle ( baseX, baseY+topsize+playersize*(i-1), width, playersize, tocolor(112,112,112,100),true,false )
end
local xoff = 60
for c, d in ipairs ( scoreboardColumns ) do
local data = d.data(playersTable[i+ploff])
local r,g,b = 255,255,255
if d.name == "grupo" and data == "none" then
r,g,b = 0,255,0
data = "Sin Grupo"
end
dxDrawText ( data, baseX+xoff, baseY+topsize+playersize*(i-1), baseX+xoff+d.width, baseY+topsize+playersize*i, tocolor(r,g,b), 1, "default-bold", "center", "center",false,false,true )
xoff = xoff+d.width
end
end
end
end
)