Turbe$Z

I created a hud, but in other resolution move up/down..Why?

Recommended Posts

local sX, sY = guiGetScreenSize()
local mainW, mainH = 285, 125
local mainX, mainY = sX-mainW-10, sY-mainH-730
local lp = getLocalPlayer()

local hudColors = {
	["main"] = tocolor(0, 0, 0, 125),
	["sub"] = tocolor(0, 0, 0, 75),
	["health"] = tocolor(255, 0, 0, 75),
	["armor"] = tocolor(255, 255, 255, 75),
	["oxygen"] = tocolor(0, 186, 255, 75) 
}


addEventHandler("onClientRender", getRootElement(), function()
	showPlayerHudComponent("all", false)
                      showPlayerHudComponent("crosshair", true)
	dxDrawRectangle(mainX, mainY, mainW, mainH, hudColors["main"])
	-- Életerő
	dxDrawRectangle(mainX+135, mainY+10, mainW-151, 20, hudColors["sub"])
	dxDrawRectangle(mainX+137, mainY+12, getElementHealth(localPlayer)*(mainW-25)/400, 16, hudColors["health"])
	dxDrawText(math.floor(getElementHealth(lp)).." élet", mainX+257, mainY+14.2, mainX+mainW-135, mainY+30, tocolor(0, 0, 0, 255), 1, "default-bold", "center", "center")
                dxDrawText(math.floor(getElementHealth(lp)).." élet", mainX+257, mainY+10, mainX+mainW-135, mainY+30, tocolor(255, 255, 255, 255), 1, "default-bold", "center", "center")
	-- Páncél
	dxDrawRectangle(mainX+135, mainY+34, mainW-150, 20, hudColors["sub"])
	dxDrawRectangle(mainX+137, mainY+36, getPedArmor(localPlayer)*(mainW-155)/100, 16, hudColors["armor"])
	dxDrawText("Életpajzs", mainX+257, mainY+38.2, mainX+mainW-135, mainY+54, tocolor(0, 0, 0, 255), 1, "default-bold", "center", "center")
                dxDrawText("Életpajzs", mainX+257, mainY+35, mainX+mainW-135, mainY+54, tocolor(255, 255, 255, 255), 1, "default-bold", "center", "center")
	-- Oxigén
	dxDrawRectangle(mainX+135, mainY+58, mainW-150, 20, hudColors["sub"])
	dxDrawRectangle(mainX+137, mainY+60, getPedOxygenLevel(localPlayer)*(mainW-155)/1000, 16, hudColors["oxygen"])
	dxDrawText("Oxigén", mainX+257, mainY+62.2, mainX+mainW-135, mainY+78, tocolor(0, 0, 0, 255), 1, "default-bold", "center", "center")
                dxDrawText("Oxigén", mainX+257, mainY+59, mainX+mainW-135, mainY+78, tocolor(255, 255, 255, 255), 1, "default-bold", "center", "center")
	-- Pénz
	local moneyLength = string.len(getPlayerMoney(localPlayer))
	dxDrawText(string.sub("FullFunPlay ", moneyLength-25, 29) ..  "#000000$" .. getPlayerMoney(localPlayer) .. "#000000", mainX+10, mainY+96.1, mainX+mainW-10, nil, tocolor(0, 0, 0, 255), 1.6, "default-bold", "right", nil, false, false, false, true)
                dxDrawText(string.sub("FullFunPlay ", moneyLength-25, 29) ..  "#00baff$" .. getPlayerMoney(localPlayer) .. "#00baff", mainX+10, mainY+93, mainX+mainW-10, nil, tocolor(255, 255, 255, 255), 1.6, "default-bold", "right", nil, false, false, false, true)
	-- Fegyver
	local pWeapon = getPedWeapon(localPlayer)
	local clipAmmo = getPedAmmoInClip(localPlayer)
	local totalAmmo = getPedTotalAmmo(localPlayer)
	--dxDrawText("Lőszer: " .. clipAmmo .. " | " .. totalAmmo-clipAmmo, mainX+100, 109.5, nil, nil, tocolor(0, 0, 0, 255), 1.1, "default-bold")
                dxDrawText("Lőszer: " .. clipAmmo .. " | " .. totalAmmo-clipAmmo, mainX+35, 120, nil, nil, tocolor(255, 255, 255, 255), 1, "default-bold")
	dxDrawImage(mainX-80, 50, 200, 100, "img/" .. pWeapon.. ".png")
end)

how to fix this problem? :S 

/sorry for my bad english/

thx the help:D

Share this post


Link to post

Its because you have not converted the positions to be relative for other resolutions.

If you are using guieditor right click on the dx element and check "relative" then it would fit other resolutions.

if you are not then get it here guieditor.

It maked creating any GUI easy.

Share this post


Link to post
11 minutes ago, loki2143 said:

Its because you have not converted the positions to be relative for other resolutions.

If you are using guieditor right click on the dx element and check "relative" then it would fit other resolutions.

if you are not then get it here guieditor.

It maked creating any GUI easy.

i can't click on dx element

Share this post


Link to post

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.