Hallo Community, ich habe ein Problem mit meinem Scoreboard unzwar funktioniert die Spielzeit einfach nicht hier der Code :
Lua
local x,y = guiGetScreenSize()
position_scoreboard = 0
function getPingColor(ping)
if (ping > 100) then
return 150,150,150
elseif (ping < 100) then
return 20,200,20
else
return 200,20,20
end
end
function drawScoreboard (player)
dxDrawRectangle(388 * x / 1440, 225 * y / 900, 670* x / 1440, 366 * y / 900, tocolor(0, 0, 0, 169), true)
dxDrawRectangle(556* x / 1440, 225 * y / 900, 1* x / 1440, 366 * y / 900, tocolor(0, 0, 0, 255), true)
dxDrawRectangle(734 * x / 1440, 225 * y / 900, 1 * x / 1440, 366 * y / 900, tocolor(0, 0, 0, 255), true)
dxDrawRectangle(963 * x / 1440, 225 * y / 900, 1 * x / 1440, 366 * y / 900, tocolor(0, 0, 0, 255), true)
dxDrawRectangle(388 * x / 1440, 225 * y / 900, 670* x / 1440, 20 * y / 900, tocolor(25, 25, 25, 255), true)
dxDrawText("Name", 405* x / 1440, 224 * y / 900, 572* x / 1440, 245 * y / 900, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "center", false, false, true, false, false)
dxDrawText("Spielzeit", 568* x / 1440, 225 * y / 900, 735* x / 1440, 246 * y / 900, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "center", false, false, true, false, false)
dxDrawText("Fraktion", 739* x / 1440, 225 * y / 900, 906* x / 1440, 246 * y / 900, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "center", false, false, true, false, false)
dxDrawText("Ping", 973* x / 1440, 225 * y / 900, 1068* x / 1440, 245 * y / 900, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "center", false, false, true, false, false)
pl = {}
local i = 0
for id, play in ipairs(getElementsByType("player")) do
local name = getPlayerName(play )
local ping = getPlayerPing(play) -- Ping
local playtime = getElementData(play,"Playtime")
local spielzeit = math.floor(playtime / 60)..":"..(playtime - math.floor(playtime / 60) * 60)
local faction = getElementData(play, "Fraktion")
pl[i] = {}
pl[i].name = name
pl[i].playtime= playtime
pl[i].playtime_m= playtime_m
pl[i].faction = faction
if faction == 0 then
pl[i].faction = "Zivillist"
elseif faction == 1 then
pl[i].faction = "LVPD"
elseif faction == 2 then
pl[i].faction = "Yakuza"
elseif faction == 3 then
pl[i].faction = "Reporter"
elseif faction == 4 then
pl[i].faction = "Army"
elseif faction == 5 then
pl[i].faction = "FBI"
elseif faction == 6 then
pl[i].faction = "ADAC"
elseif faction == 7 then
pl[i].faction = "Los Aztecas"
elseif faction == 8 then
pl[i].faction = "Terroristen"
elseif faction == 9 then
pl[i].faction = "Mafia"
elseif faction == 10 then
pl[i].faction = "Angels"
elseif faction == 11 then
pl[i].faction = "Hitman"
elseif faction == 12 then
pl[i].faction = "Sanitäter"
elseif faction == 13 then
pl[i].faction = "Razor"
end
pl[i].ping = ping
i = i + 1
end
row = 0
for i = 0+position_scoreboard , 18+position_scoreboard do
if pl[i] then
dxDrawText(pl[i].name, 395* x / 1440, 249 * y / 900 +(18*row), 546* x / 1440, 265 * y / 900 +(18*row), tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "center", false, false, true, false, false)
dxDrawText(spielzeit, 568* x / 1440, 250 * y / 900 +(18*row), 719* x / 1440, 266 * y / 900 +(18*row), tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "center", false, false, true, false, false)
dxDrawText(pl[i].faction, 739* x / 1440, 250 * y / 900 +(18*row), 952* x / 1440, 267 * y / 900 +(18*row), tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "center", false, false, true, false, false)
r,g,b = getPingColor(pl[i].ping)
dxDrawText(pl[i].ping, 973* x / 1440, 250 * y / 900 +(18*row), 1048* x / 1440, 267 * y / 900 +(18*row), tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "center", false, false, true, false, false)
row = row + 1
end
end
end
bindKey("tab","down",function()
addEventHandler("onClientRender", root, drawScoreboard)
bindKey("mouse_wheel_down","down",scrollDown)
bindKey("mouse_wheel_up","down",scrollUp)
toggleControl("next_weapon",false)
toggleControl("previous_weapon",false)
toggleControl("fire",false)
end)
bindKey("tab","up",function()
unbindKey("mouse_wheel_down","down",scrollDown)
unbindKey("mouse_wheel_up","down",scrollUp)
removeEventHandler("onClientRender", root, drawScoreboard)
toggleControl("next_weapon",true)
toggleControl("previous_weapon",true)
toggleControl("fire",true)
end)
function scrollDown()
if getElementsByType("player") - position_scoreboard <= 2 then
position_scoreboard = #getElementsByType("player")
else
position_scoreboard = position_scoreboard + 2
end
end
function scrollUp()
if position_scoreboard <= 2 then
position_scoreboard = 0
else
position_scoreboard = position_scoreboard - 2
end
end
Alles anzeigen