getPlayersOnline = function ()
local playersOnline = getElementsByType ( "player" )
local playersO = 0
for count, playerOn in pairs(playersOnline) do
playersO = playersO + 1
end
return playersO
end
That function is completely useless, you can simply use:
playersO = #getElementsByType ( "player" )
About the other problem, try this:
function Scoreboard()
dxDrawImage(X,Y,Width,Height, "images/back.png")
dxDrawText("Name", X+60, Y+10, Width,Height, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false)
dxDrawText(getPlayersOnline().."/50" ,X+525, Y-15, Width,Height, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
dxDrawText("Ping", X+480, Y+10, Width, Height, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false)
dxDrawText("Geld", X+210, Y+10, Width, Height, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false)
dxDrawText("Team", X+350, Y+10, Width, Height, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false)
local players = getElementsByType ( "player" )
local playas = 0
local playerheight = 20
for amt, player in pairs(players) do
playas = playas + 1
if (playas <= 20) then
local ping = getPlayerPing(player)
local teamp = getPlayerTeam(player)
local teamn = getTeamName(teamp)
local money = tonumber ( getElementData(player, "playerMoney") ) or 0
if (ping >= 250) then
r,g,b = 255,0,0
elseif (ping >= 120) then
r,g,b = 255,69,0
else
r,g,b = 0,255,0
end
dxDrawText(getPlayerName ( player ), X+60,Y+60+playerheight*(amt-1), Width,Height, tocolor(255,255,255), 1 , "default-bold","left", "top",false, false,true,true)
dxDrawText(ping,X+480,Y+60+playerheight*(amt-1), Width, Height, tocolor(r,g,b), 1, "default","left", "top",false,false,true,true)
dxDrawText( tostring ( money ) .." $", X+210,Y+60+playerheight*(amt-1),Width, Height, tocolor(255,255,255), 1, "default","left", "top",false, false, true, true)
dxDrawText(teamn, X+350,Y+60+playerheight*(amt-1),Width, Height, tocolor(255,255,255), 1, "default","left", "top",false, false, true, true)
end
end
end