Jump to content

Ajuda em HUD, resolução


Recommended Posts

Bom, criei um "complemento" para um hud já existente, mas ele foi criado em uma pasta diferente.

Então, criei a hud, estava funcionando(minha resolução 1280x720), so que, quando testo em outras resoluções(1366x766; 1360;760; etc) ela buga ( https://prnt.sc/mm5y2w aqui ela está em 1366x768)

Qual pode ser o erro?

Segue abaixo: 


local screenW, screenH = guiGetScreenSize()
local resW, resH = 1366, 768
local x, y =  ( screenW/resW ), ( screenH/resH )

function drawHUD()
        local estrelasprocurado = getPlayerWantedLevel (localPlayer)
        local ArmaAtual = getPedWeapon(localPlayer)
        local MunicaoPente = getPedAmmoInClip (localPlayer)
        local MunicaoTotal = getPedTotalAmmo (localPlayer)

        dxDrawImage(x*0.8430, y*0.0375, x*0.2000, y*0.1778, ":[BR]HUDRPComplemento/img/"..ArmaAtual..".png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawRectangle(x*1142, y*187, x*80, y*0, tocolor(255, 255, 255, 255), false)
        dxDrawRectangle(x*0.8945, y*0.2014, x*0.1039, y*0.0306, tocolor(0, 0, 0, 109), false)
        dxDrawText("Munição: "..MunicaoPente.."/"..MunicaoTotal, x*1161, y*135, x*1268, y*177, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
        dxDrawRectangle(x*0.7867, y*0.0431, x*0.0000, y*0.0306, tocolor(255, 255, 255, 255), false)
        dxDrawRectangle(x*0.7867, y*0.0431, x*0.1016, y*0.0306, tocolor(0, 0, 0, 84), false)
        dxDrawText("Estrelas: "..estrelasprocurado, x*1034, y*37, x*1114, y*51, tocolor(255, 255, 255, 255), x*0.98, "default", "center", "top", false, false, false, false, false)
        dxDrawRectangle(x*873, y*31, x*130, y*22, tocolor(0, 0, 0, 84), false)
        dxDrawText("Desempregado", x*898, y*37, x*961, y*51, tocolor(255, 255, 255, 255), x*0.95, "default", "left", "top", false, false, false, false, false)
        dxDrawLine(x*874, y*51, x*874, y*51, tocolor(255, 255, 255, 255), x*1, false)
        dxDrawLine(x*873, y*53, x*1002, y*53, tocolor(255, 255, 255, 255), x*1, false)
        dxDrawLine(x*1008, y*53, x*1137, y*53, tocolor(255, 255, 255, 255), x*1, false)
        dxDrawLine(x*1147, y*167, x*1276, y*167, tocolor(255, 255, 255, 255), x*1, false)
end
addEventHandler("onClientRender", getRootElement(), drawHUD)

function toggleRadar()
	if isVisible then
		addEventHandler("onClientRender", root, drawHUD )
	else
		removeEventHandler("onClientRender", root, drawHUD )
	end
	isVisible = not isVisible
end
bindKey ("F11", "down", toggleRadar)



local hudTable = 
{
"ammo",
"armour",
"clock",
"health",
"money",
"weapon",
"wanted",
"area_name",
"vehicle_name",
"breath",
"clock"
}

addEventHandler("onClientResourceStart", resourceRoot,
    function()
	for id, hudComponents in ipairs(hudTable) do
		showPlayerHudComponent(hudComponents, false)
	end
    end
)

addEventHandler("onClientResourceStop", resourceRoot,
    function()
	for id, hudComponents in ipairs(hudTable) do
		showPlayerHudComponent(hudComponents, true)
	end
    end
)

 

Link to comment
  • Moderators

Você deve definir a resolução que você fez a interface na linha 3 e não outra resolução que esteja dando problemas.

Além disso, se você quer mesmo ajustar as dimensões de cada elemento bem como as posições, tenha em mente que será necessário outros cálculos, como ajustar o tamanho da fonte do texto-dx.

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