Jump to content

Scoreboard bug, overlapping names


Recommended Posts

 

id = 0
if (spectators==true) then
		local i = 1
		 spectators = {}
		  spectators[i] = {}
          local players = getPlayersInTeam(getTeamFromName ( "Spectators" )) or 0
           for k,v in ipairs(players) do 
			spectators[i].name = getPlayerName(v)
            spectators[i].fps = getElementData(v,"fps")
			spectators[i].ping = getPlayerPing(v)
			
		  dxDrawRectangle(screenW * 0.2977, screenH * 0.3583+33*id, screenW * 0.4055, screenH * 0.0431, tocolor(40, 40, 40, 114), false)
   	      dxDrawText(spectators[i].name, screenW * 0.3063, screenH * 0.3694+33*id, screenW * 0.3633, screenH * 0.3917, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, true, false)
       
          dxDrawText(spectators[i].fps or 0, screenW * 0.6281, screenH * 0.3681+33*id, screenW * 0.6453, screenH * 0.3875, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false)
          dxDrawText(spectators[i].ping, screenW * 0.6672, screenH * 0.3681+33*id, screenW * 0.6844, screenH * 0.3875, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false)
		 
		 end
         i = i + 1

        end 	
		
		if scoreboard == true then
		bindKey( "mouse2", "both", showTheCursor )
		else
		unbindKey( "mouse2", "both", showTheCursor )
		end
		
      end
	   id = id + 1 
   end
end

Alright so what it does is -

DFPE1S9.png

It overlaps the names, instead of inserting them on a new line

Link to comment

you have to make a variable with coordinates of first rectangle and text (and put the creation of both in a event on player join)
and when player joins make the variable number get higher or lower to display it on a new line .

Edited by 3laa33
Link to comment
function dxDrawScoreboard()
		scoreboard = true
        id = 0
        dxDrawRectangle(screenW * 0.2086, screenH * 0.2778, screenW * 0.0891, screenH * 0.4889, tocolor(52, 52, 52, 248), false)
        dxDrawRectangle(screenW * 0.2977, screenH * 0.2333, screenW * 0.4055, screenH * 0.5333, tocolor(52, 52, 52, 200), false)
        dxDrawRectangle(screenW * 0.2977, screenH * 0.7236, screenW * 0.4055, screenH * 0.0431, tocolor(43, 43, 43, 255), false)
        dxDrawRectangle(screenW * 0.2977, screenH * 0.3083, screenW * 0.4055, screenH * 0.0431, tocolor(43, 43, 43, 255), false)
        dxDrawText("Name", screenW * 0.3117, screenH * 0.3167, screenW * 0.3367, screenH * 0.3444, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
        dxDrawText("Country", screenW * 0.5141, screenH * 0.3167, screenW * 0.5500, screenH * 0.3444, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
        dxDrawText("FPS", screenW * 0.6281, screenH * 0.3167, screenW * 0.6641, screenH * 0.3444, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
        dxDrawText("Ping", screenW * 0.6672, screenH * 0.3167, screenW * 0.7031, screenH * 0.3444, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
        dxDrawRectangle(screenW * 0.2086, screenH * 0.2778, screenW * 0.0891, screenH * 0.0444, tocolor(44, 44, 44, 248), false)
        dxDrawText("TEAMS", screenW * 0.2086, screenH * 0.2778, screenW * 0.2977, screenH * 0.3222, tocolor(255, 255, 255, 255), 1.50, "default-bold", "center", "center", false, false, false, false, false)
       
	    dxDrawRectangle(screenW * 0.2086, screenH * 0.3333, screenW * 0.0883, screenH * 0.0403, tocolor(40, 40, 40, 248), false)
        dxDrawText("Team 1", screenW * 0.2086, screenH * 0.3333, screenW * 0.2969, screenH * 0.3722, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
        
		dxDrawRectangle(screenW * 0.2086, screenH * 0.3875, screenW * 0.0883, screenH * 0.0403, tocolor(40, 40, 40, 248), false)
        dxDrawText("Team 2", screenW * 0.2086, screenH * 0.3875, screenW * 0.2969, screenH * 0.4278, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
        
		local r,g,c
			if isMouseInPosition(screenW * 0.2094, screenH * 0.4472, screenW * 0.0883, screenH * 0.0403) then 
			r,g,c = 80, 80, 80
			spectators = true
			else
			r,g,c = 40, 40, 40
			spectators = false
			end
        local specs = getTeamFromName ( "Spectators" )
		local speccounter = countPlayersInTeam ( specs ) or 0
		
	    dxDrawRectangle(screenW * 0.2094, screenH * 0.4472, screenW * 0.0883, screenH * 0.0403, tocolor(r, g, c, 248), false)
		dxDrawText("Spectators".." ("..speccounter..")", screenW * 0.2078, screenH * 0.4472, screenW * 0.2977, screenH * 0.4875, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)

	    dxDrawRectangle(screenW * 0.2094, screenH * 0.5097, screenW * 0.0883, screenH * 0.0431, tocolor(40, 40, 40, 248), false)		
		dxDrawText("Referees", screenW * 0.2086, screenH * 0.5097, screenW * 0.2977, screenH * 0.5500, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
       
		dxDrawText(#getElementsByType("player").."/50", screenW * 0.6672, screenH * 0.2625, screenW * 0.7508, screenH * 0.3083, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
        dxDrawText("Players:", screenW * 0.6672, screenH * 0.2486, screenW * 0.7109, screenH * 0.2986, tocolor(255, 255, 255, 255), 0.60, "default-bold", "left", "top", false, false, false, false, false)
        dxDrawText("Welcome to FTW Gaming's Clanwar Server!", screenW * 0.3195, screenH * 0.2542, screenW * 0.4039, screenH * 0.3028, tocolor(255, 255, 255, 255), 1.50, "default", "left", "top", false, false, false, false, false)
        
		
		for i = 1+scroll,8+scroll do
		  if (players[i] and not spectators == true) then
		    dxDrawRectangle(screenW * 0.2977, screenH * 0.3583+33*id, screenW * 0.4055, screenH * 0.0431, tocolor(40, 40, 40, 114), false)
   	    dxDrawText(players[i].name, screenW * 0.3063, screenH * 0.3694+33*id, screenW * 0.3633, screenH * 0.3917, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, true, false)
       
        dxDrawText(players[i].fps, screenW * 0.6281, screenH * 0.3681+33*id, screenW * 0.6453, screenH * 0.3875, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false)
        dxDrawText(players[i].ping, screenW * 0.6672, screenH * 0.3681+33*id, screenW * 0.6844, screenH * 0.3875, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false)
		else
		if (spectators==true) then
		local i = 1
		 spectators = {}
		  spectators[i] = {}
          local players = getPlayersInTeam(getTeamFromName ( "Spectators" )) or 0
           for k,v in ipairs(players) do 
			spectators[i].name = getPlayerName(v)
            spectators[i].fps = getElementData(v,"fps")
			spectators[i].ping = getPlayerPing(v)
			
		  dxDrawRectangle(screenW * 0.2977, screenH * 0.3583+33*id, screenW * 0.4055, screenH * 0.0431, tocolor(40, 40, 40, 114), false)
   	      dxDrawText(spectators[i].name, screenW * 0.3063, screenH * 0.3694+33*id, screenW * 0.3633, screenH * 0.3917, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, true, false)
       
          dxDrawText(spectators[i].fps or 0, screenW * 0.6281, screenH * 0.3681+33*id, screenW * 0.6453, screenH * 0.3875, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false)
          dxDrawText(spectators[i].ping, screenW * 0.6672, screenH * 0.3681+33*id, screenW * 0.6844, screenH * 0.3875, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false)
		 
		 end
         i = i + 1

        end 	
		
		if scoreboard == true then
		bindKey( "mouse2", "both", showTheCursor )
		else
		unbindKey( "mouse2", "both", showTheCursor )
		end
		
      end
	   id = id + 1 
   end
end

It works for normal players like when they normally press TAB, but when they go to spectators, it just overlaps.

Link to comment

That's because you multiply the index of the current row by 33. But the calculation is the same in both tables, they are both multiplied by 33.What you should do is add some more calculation to the spectator rows. Try something like this:

 dxDrawText(spectators[i].name, screenW * 0.3063, screenH * 0.3694+33*id + #players * 33, screenW * 0.3633, screenH * 0.3917, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, true, false)

 

Link to comment
	local players = {}
	local spectators = {}
local scroll = 0
local player = client
local scoreboard
local root = getRootElement()
local player = getLocalPlayer()
local counter = 0
local starttick
local currenttick

addEventHandler("onClientRender",root,
	function()
		if not starttick then
			starttick = getTickCount()
		end
		counter = counter + 1
		currenttick = getTickCount()
		if currenttick - starttick >= 1000 then
			setElementData(player,"fps",counter)
			counter = 0
			starttick = false
		end
	end
)

function onPlayerJoinToServer()
	if source then
		findIDForPlayer(source)
		local country = call(getResourceFromName("admin"),"getPlayerCountry",source)
		if country then
			setElementData(source,"country",country)
		else
			setElementData(source,"country","?")
		end
	end
end
addEventHandler("onPlayerJoin",getRootElement(),onPlayerJoinToServer)


function findIDForPlayer(thePlayer)
	if thePlayer and not getElementData(thePlayer,"ID") then
		local i = 0
		local players = getElementsByType("player")
		repeat 
			local foundID = false
			i = i + 1
			for _,player in pairs(players) do
				if player ~= thePlayer then
					local playerID = tonumber(getElementData(player,"ID"))
					if playerID == i then
						foundID = true
						break
					end
				end
			end
		until not foundID
		setElementData(thePlayer,"ID",i)
	end
end

function onServerIDStart()
	for i,thePlayer in pairs(getElementsByType("player")) do
		findIDForPlayer(thePlayer)
		local country = call(getResourceFromName("admin"),"getPlayerCountry",source)
		if country then
			setElementData(source,"country",country)
		else
			setElementData(source,"country","?")
		end
	end
end
addEventHandler("onResourceStart",resourceRoot,onServerIDStart)

function setScoreboardValues(thePlayer)
   players = {}
   
   local i = 1
     for k, v in pairs(getElementsByType("player")) do
	   local player = getPlayerName(v)
	   playername = tostring ( player ):gsub( "_", " " );
	   playerping = getPlayerPing(v);
	   
	   players[i] = {}
       players[i].name = playername
	   players[i].ping = playerping
	   players[i].country = getElementData(v,"country")
	   local playerTeam = getPlayerTeam ( v )  
	   players[i].teamname = getTeamName ( playerTeam )
	   		if not starttick then
			starttick = getTickCount()
		end
		counter = counter + 1
		currenttick = getTickCount()
		if currenttick - starttick >= 1000 then
			setElementData(v,"fps",counter)
			counter = 0
			starttick = false
		end
	
	
	players[i].fps = getElementData(v,"fps")
	
	   i = i + 1 
	end
end

local screenW, screenH = guiGetScreenSize()
scoreboard = false	
spectators = false
team1 = false
team2 = false
referees = false

function dxDrawScoreboard()
		scoreboard = true
        id = 0
		ids = 0
        dxDrawRectangle(screenW * 0.2086, screenH * 0.2778, screenW * 0.0891, screenH * 0.4889, tocolor(52, 52, 52, 248), false)
        dxDrawRectangle(screenW * 0.2977, screenH * 0.2333, screenW * 0.4055, screenH * 0.5333, tocolor(52, 52, 52, 200), false)
        dxDrawRectangle(screenW * 0.2977, screenH * 0.7236, screenW * 0.4055, screenH * 0.0431, tocolor(43, 43, 43, 255), false)
        dxDrawRectangle(screenW * 0.2977, screenH * 0.3083, screenW * 0.4055, screenH * 0.0431, tocolor(43, 43, 43, 255), false)
        dxDrawText("Name", screenW * 0.3117, screenH * 0.3167, screenW * 0.3367, screenH * 0.3444, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
        dxDrawText("Country", screenW * 0.5141, screenH * 0.3167, screenW * 0.5500, screenH * 0.3444, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
        dxDrawText("FPS", screenW * 0.6281, screenH * 0.3167, screenW * 0.6641, screenH * 0.3444, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
        dxDrawText("Ping", screenW * 0.6672, screenH * 0.3167, screenW * 0.7031, screenH * 0.3444, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
        dxDrawRectangle(screenW * 0.2086, screenH * 0.2778, screenW * 0.0891, screenH * 0.0444, tocolor(44, 44, 44, 248), false)
        dxDrawText("TEAMS", screenW * 0.2086, screenH * 0.2778, screenW * 0.2977, screenH * 0.3222, tocolor(255, 255, 255, 255), 1.50, "default-bold", "center", "center", false, false, false, false, false)
       
	    dxDrawRectangle(screenW * 0.2086, screenH * 0.3333, screenW * 0.0883, screenH * 0.0403, tocolor(40, 40, 40, 248), false)
        dxDrawText("Team 1", screenW * 0.2086, screenH * 0.3333, screenW * 0.2969, screenH * 0.3722, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
        
		dxDrawRectangle(screenW * 0.2086, screenH * 0.3875, screenW * 0.0883, screenH * 0.0403, tocolor(40, 40, 40, 248), false)
        dxDrawText("Team 2", screenW * 0.2086, screenH * 0.3875, screenW * 0.2969, screenH * 0.4278, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
        
		local r,g,c
			if isMouseInPosition(screenW * 0.2094, screenH * 0.4472, screenW * 0.0883, screenH * 0.0403) then 
			r,g,c = 80, 80, 80
			spectators = true
			else
			r,g,c = 40, 40, 40
			spectators = false
			end
        local specs = getTeamFromName ( "Spectators" )
		local speccounter = countPlayersInTeam ( specs ) or 0
		
	    dxDrawRectangle(screenW * 0.2094, screenH * 0.4472, screenW * 0.0883, screenH * 0.0403, tocolor(r, g, c, 248), false)
		dxDrawText("Spectators".." ("..speccounter..")", screenW * 0.2078, screenH * 0.4472, screenW * 0.2977, screenH * 0.4875, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)

	    dxDrawRectangle(screenW * 0.2094, screenH * 0.5097, screenW * 0.0883, screenH * 0.0431, tocolor(40, 40, 40, 248), false)		
		dxDrawText("Referees", screenW * 0.2086, screenH * 0.5097, screenW * 0.2977, screenH * 0.5500, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
       
		dxDrawText(#getElementsByType("player").."/50", screenW * 0.6672, screenH * 0.2625, screenW * 0.7508, screenH * 0.3083, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false)
        dxDrawText("Players:", screenW * 0.6672, screenH * 0.2486, screenW * 0.7109, screenH * 0.2986, tocolor(255, 255, 255, 255), 0.60, "default-bold", "left", "top", false, false, false, false, false)
        dxDrawText("Welcome to FTW Gaming's Clanwar Server!", screenW * 0.3195, screenH * 0.2542, screenW * 0.4039, screenH * 0.3028, tocolor(255, 255, 255, 255), 1.50, "default", "left", "top", false, false, false, false, false)
        
		
		for i = 1+scroll,8+scroll do
		  if (players[i] and not spectators == true) then
		    dxDrawRectangle(screenW * 0.2977, screenH * 0.3583+33*id, screenW * 0.4055, screenH * 0.0431, tocolor(40, 40, 40, 114), false)
   	    dxDrawText(players[i].name, screenW * 0.3063, screenH * 0.3694+33*id, screenW * 0.3633, screenH * 0.3917, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, true, false)
       
        dxDrawText(players[i].fps, screenW * 0.6281, screenH * 0.3681+33*id, screenW * 0.6453, screenH * 0.3875, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false)
        dxDrawText(players[i].ping, screenW * 0.6672, screenH * 0.3681+33*id, screenW * 0.6844, screenH * 0.3875, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false)
		else
		if (spectators==true) then
		 spectators = {}
		  spectators[i] = {}
          local players = getPlayersInTeam(getTeamFromName ( "Spectators" )) or 0
           for k,v in ipairs(players) do 
			spectators[i].name = getPlayerName(v)
            spectators[i].fps = getElementData(v,"fps")
			spectators[i].ping = getPlayerPing(v)
			
		  dxDrawRectangle(screenW * 0.2977, screenH * 0.3583+33*ids, screenW * 0.4055, screenH * 0.0431, tocolor(40, 40, 40, 114), false)
   	      dxDrawText(spectators[i].name, screenW * 0.3063, screenH * 0.3694+33*ids, screenW * 0.3633, screenH * 0.3917, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, true, false)
       
          dxDrawText(spectators[i].fps or 0, screenW * 0.6281, screenH * 0.3681+33*ids, screenW * 0.6453, screenH * 0.3875, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false)
          dxDrawText(spectators[i].ping, screenW * 0.6672, screenH * 0.3681+33*ids, screenW * 0.6844, screenH * 0.3875, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false)
		 
		 end
         i = i + 1

        end 	
		
		if scoreboard == true then
		bindKey( "mouse2", "both", showTheCursor )
		else
		unbindKey( "mouse2", "both", showTheCursor )
		end
		
      end
	   id = id + 1 
	   ids = ids + 1
   end
end

function isMouseInPosition ( x, y, width, height )
    if ( not isCursorShowing ( ) ) then
        return false
    end
 
    local sx, sy = guiGetScreenSize ( ) -- Get the player screen resolution
    local cx, cy = getCursorPosition ( ) -- Get the cursor position
    local cx, cy = ( cx * sx ), ( cy * sy ) -- Convert relative positions to absolute
    if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
        return true
    else
        return false
    end
end

function showTheCursor( _, state )
	if state == "down" then
		showCursor( true )
	else
		if not (scoreboard==true) then
			showCursor( false )
		end
	end
end

local function onToggleKey ( key, keyState )
	if not scoreboard then
		local elementTable = getElementsByType ( "scoreboard" )
		if #elementTable > 0 then
			scoreboard = elementTable[1]
		else
			return
		end
	end
end
bindKey ( "tab", "both", onToggleKey )

bindKey("tab", "down", function()
   addEventHandler("onClientRender", root, dxDrawScoreboard)
   bindKey("mouse_wheel_up", "down", scroll_up)
   bindKey("mouse_wheel_down", "down", scroll_down)
   updateTimer = setTimer(function ()
   setScoreboardValues();
   end, 100, 0)
end)


bindKey("tab", "up", function()
   removeEventHandler("onClientRender", root, dxDrawScoreboard)
   scoreboard = false
   		unbindKey( "mouse2", "both", showTheCursor )
		showCursor(false)
   unbindKey("mouse_wheel_up", "down", scroll_up)
   unbindKey("mouse_wheel_down", "down", scroll_down)
   killTimer(updateTimer)
end)

function scroll_up()
   if (scroll <= 2) then
      scroll = 0
   else
      scroll = scroll - 2
   end
end

function scroll_down()
   if (#getElementsByType("player") <= 2) then
      scroll = #getElementsByType("player")
   else
      scroll = scroll + 2
   end
end

Here's the full script.

Link to comment

Didn't I already do that for spectators?

In this part -

if (spectators==true) then
		 spectators = {}
		  spectators[i] = {}
          local players = getPlayersInTeam(getTeamFromName ( "Spectators" )) or 0
           for k,v in ipairs(players) do 
			spectators[i].name = getPlayerName(v)
            spectators[i].fps = getElementData(v,"fps")
			spectators[i].ping = getPlayerPing(v)
			
		  dxDrawRectangle(screenW * 0.2977, screenH * 0.3583+33*ids, screenW * 0.4055, screenH * 0.0431, tocolor(40, 40, 40, 114), false)
   	      dxDrawText(spectators[i].name, screenW * 0.3063, screenH * 0.3694+33*ids, screenW * 0.3633, screenH * 0.3917, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, true, false)
       
          dxDrawText(spectators[i].fps or 0, screenW * 0.6281, screenH * 0.3681+33*ids, screenW * 0.6453, screenH * 0.3875, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false)
          dxDrawText(spectators[i].ping, screenW * 0.6672, screenH * 0.3681+33*ids, screenW * 0.6844, screenH * 0.3875, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false)
		 
		 end

 

Link to comment

I just tested your code and it seemed to work fine for me. I only added some entries to the players table and I could only see it for a second before it disappeared.

But here's one example of how I would do it:

local players = {
	{name = "Jack", ping = 22, fps = 59, country = "US"},
	{name = "Jill", ping = 26, fps = 59, country = "US"},
}

local offset = 20

addEventHandler("onClientRender", root,
	function()
		for i=1, #players do
			local item = players[i]
			if item then
				local y = offset * (i - 1)
				dxDrawText(item.name, 200, 302 + y), 847, 350, tocolor(255, 255, 255, 255), 1.50, "default", "left", "top", false, false, false, false, false)
			end			
		end
	end
)

 

Link to comment

No, as a whole the scoreboard works perfectly fine. But lets say, if the players join the spectators team right, and on the scoreboard if there's more than 1 spectator, the rectangles/names just to hover over each other. And I can't figure out where I'm gone wrong.

They overlap, I tried different calculations, but I always get the same result.

Link to comment

Okay I'm trying something else - 

if (spectators==true) then
		 spectators = {}
		  spectators[i] = {}
          local spectatorteam = getPlayersInTeam(getTeamFromName ( "Spectators" )) or 0
           for i=1, #spectatorteam do
			spectators[i].name = getPlayerName(v)
            spectators[i].fps = getElementData(v,"fps")
			spectators[i].ping = getPlayerPing(v)
			local y = offset * (i - 1)

How would I get the separate people's data if I do it this way?

Edited by raysmta
Link to comment

This code editor is so messed up, I can barely see where an if, function or a loop starts, the old one used to be way better. Anyway, I see you added this part

screenH * 0.3583+33*ids

Where you multiply by the ids, but do you update the ids at every iteration of the loop?

I still don't understand what you're trying to do exactly, do you want to list out all the non spectators first then the spectators? 

Link to comment

It already does that, when the scoreboard opens, it lists all the players. Then once the mouse hovers over the 'Spectators' it lists the spectators but, then it overlaps all the current spectators, whereas, I am trying to make them all on separate lines. It's possible if I do 

screenH * 0.3583+33*ids+(k*33)

But then it just creates a huge gap.

Link to comment

Oh, so you want to display all the non-specs and then when the player hovers over a button/text display the spectators only? I see, try this:

local players = getPlayersInTeam(getTeamFromName ( "Spectators" )) or 0
for i = 1, #players do 
	spectators[i].name = getPlayerName(players[i])
    spectators[i].fps = getElementData(players[i],"fps")
	spectators[i].ping = getPlayerPing(players[i])
			
	dxDrawRectangle(screenW * 0.2977, screenH * 0.3583+33*i, screenW * 0.4055, screenH * 0.0431, tocolor(40, 40, 40, 114), false)
   	dxDrawText(spectators[i].name, screenW * 0.3063, screenH * 0.3694+33*i, screenW * 0.3633, screenH * 0.3917, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, true, false)
       
    dxDrawText(spectators[i].fps or 0, screenW * 0.6281, screenH * 0.3681+33*i, screenW * 0.6453, screenH * 0.3875, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false)
    dxDrawText(spectators[i].ping, screenW * 0.6672, screenH * 0.3681+33*i, screenW * 0.6844, screenH * 0.3875, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false)
		 
end

I changed the for k, v in ipairs loop.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...