Jump to content

Scoreboard


Jmaniacs

Recommended Posts

Tengo unos problemas, y esque jamas habia hecho un scoreboard, pero el tema es que se crea todo bien y tal, pero a la hora de que otro jugador entra, ve los nombres en distintas posiciones. A ver si con imagenes me entienden mejor, agradeceria su ayuda.
 

Codigo:

Spoiler

Client>


local screenW, screenH = guiGetScreenSize()
local width,height = 300, 400

function drawTablist(thePlayer)
	if getKeyState("tab") and getElementData(localPlayer, "logged") then
		dxDrawRectangle(screenW * 0.3771, screenH * 0.2589, screenW * 0.2465, screenH * 0.4822, tocolor(0, 0, 0, 161), false)
        dxDrawRectangle(screenW * 0.3611, screenH * 0.2122, screenW * 0.2778, screenH * 0.0411, tocolor(0, 0, 0, 226), false)
        dxDrawLine(screenW * 0.3778, screenH * 0.2867, screenW * 0.6236, screenH * 0.2867, tocolor(255, 255, 255, 255), 2, false)
        dxDrawText("ID", screenW * 0.3778, screenH * 0.2589, screenW * 0.4069, screenH * 0.2867, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("Nombre", screenW * 0.4167, screenH * 0.2589, screenW * 0.5799, screenH * 0.2867, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("Ping", screenW * 0.5792, screenH * 0.2589, screenW * 0.6236, screenH * 0.2867, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("Oregon States RP V1.2", screenW * 0.3611, screenH * 0.2133, screenW * 0.6375, screenH * 0.2522, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
		dxDrawRectangle(screenW * 0.3771, screenH * 0.7467, screenW * 0.2465, screenH * 0.0267, tocolor(0, 0, 0, 209), false)
        dxDrawText("Desarrollado por Jmaniacs", screenW * 0.3771, screenH * 0.7478, screenW * 0.4750, screenH * 0.7733, tocolor(255, 255, 255, 255), 0.90, "default-bold", "left", "center", false, false, false, false, false)
		local players = getElementsByType( "player" )
        dxDrawText(tostring( #players ).." Jugador(es) Online", screenW * 0.5257, screenH * 0.7467, screenW * 0.6236, screenH * 0.7722, tocolor(255, 255, 255, 255), 0.90, "default-bold", "right", "center", false, false, false, false, false)
		for k,v in ipairs(players)do
			local id = getElementData(v,"ID")
		dxDrawText(getPlayerName(v):gsub("#%x%x%x%x%x%x", ""), screenW * 0.4097, screenH * 0.2978 * (k-0.05) / (k/8) - 1780 , screenW * 0.5757, screenH * 0.3256, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
		dxDrawText(id, screenW * 0.3778, screenH * 0.2978 * (k-0.05) / (k/8) - 1780, screenW * 0.4069, screenH * 0.3256, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
		dxDrawText(getPlayerPing(v), screenW * 0.5708, screenH * 0.2978 * (k-0.05) / (k/8) - 1780, screenW * 0.6222, screenH * 0.3256, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
			
		
		end
	end
end	
addEventHandler("onClientRender", root, drawTablist)

Server>


ID = {}


------------------------- [ Events ] --------------------------

addEventHandler("onPlayerJoin", root, 
function()
    for i = 1, getMaxPlayers() do
	    if not ID[i] then
		   ID[i] = source
		   setElementData(source, "ID", i)
		   break
		end
	end
end)

--

addEventHandler("onPlayerQuit", root, 
function()
    ID[getPlayerID(source)] = nil
end)

--

addEventHandler("onResourceStart", resourceRoot, 
function()
    for _, v in ipairs(getElementsByType("player")) do
	    for i = 1, getMaxPlayers() do
		    if not ID[i] then
			   ID[i] = v
			   setElementData(v, "ID", i)
			   break
			end
		end
	end
end)

------------------------- [ Functions ] -----------------------

function getPlayerID(player)
    if player and isElement(player) and getElementType(player) == "player" then
	   return getElementData(player, "ID")
	end
	return false
end

--

function getPlayerFromID(id)
    if id and tonumber(id)  then
	   return ID[tonumber(id)]
	end
	return false
end


addCommandHandler("id",function(source, cmd)
	local id = getElementData(source,"ID") 
	outputChatBox("Tu ID es "..id, source, 255, 255, 255)
end)

 

Imagenes:

Spoiler

Como lo veo yo o alguien con la misma resolucion mia:

OhGCN3u.png

Como lo ve una persona con otra resolucion (Este es solo un ejemplo, la otra persona lo ve en otras posiciones) :

fy4VgsX.png

 

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...