Jump to content

preciso de ajuda com uma hud


Recommended Posts

oi, sou novo na area de programaçao em .lua e fazer paineis dx.

bom resolvi fazer uma hud, o mta reconhece o script mas a hud na aparece quando executo o mesmo.

codigo:

local screenW, screenH = guiGetScreenSize()

    function hud ()

        local vida = getElementHealth ( localPlayer )
        local colete = getPedArmor ( localPlayer )
        local muniçao = getPedAmmoInClip ( localPlayer )
        local total = getPedTotalAmmo ( localPlayer )
        local Oxigenio = getPedOxygenLevel ( localPlayer )
        local dinheiro = getPlayerMoney ( localPlayer )
        local arma = gerPedWeapon ( localPlayer )

        local vidaatual = (screenW * 0.0889) * (vida/100)
        local coleteatual = (screenW * 0.0889) * (colete/100)

        dxDrawRectangle(screenW * 0.7148, screenH * 0.0000, screenW * 0.2852, screenH * 0.0859, tocolor(0, 0, 0, 193), false)
        dxDrawImage(screenW * 0.7246, screenH * 0.0195, screenW * 0.0381, screenH * 0.0430, ":Hud/img/22.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawRectangle(screenW * 0.7686, screenH * 0.0273, screenW * 0.0889, screenH * 0.0273, tocolor(173, 0, 0, 126), false)
        dxDrawRectangle(screenW * 0.7686, screenH * 0.0273, vidaatual, screenH * 0.0273, tocolor(173, 0, 0, 254), false)
        dxDrawImage(screenW * 0.8633, screenH * 0.0143, screenW * 0.0342, screenH * 0.0456, ":Hud/img/27.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawRectangle(screenW * 0.9014, screenH * 0.0273, screenW * 0.0889, screenH * 0.0273, tocolor(116, 116, 116, 141), false)
        dxDrawRectangle(screenW * 0.9014, screenH * 0.0273, coleteatual, screenH * 0.0273, tocolor(116, 116, 116, 254), false)
        dxDrawImage(screenW * 0.7207, screenH * 0.0859, screenW * 0.0576, screenH * 0.0716, ":Hud/armas/"..arma..".png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawText("1|0", (screenW * 0.7246) - 1, (screenH * 0.1589) - 1, (screenW * 0.7725) - 1, (screenH * 0.1797) - 1, tocolor(0, 0, 0, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("1|0", (screenW * 0.7246) + 1, (screenH * 0.1589) - 1, (screenW * 0.7725) + 1, (screenH * 0.1797) - 1, tocolor(0, 0, 0, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("1|0", (screenW * 0.7246) - 1, (screenH * 0.1589) + 1, (screenW * 0.7725) - 1, (screenH * 0.1797) + 1, tocolor(0, 0, 0, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("1|0", (screenW * 0.7246) + 1, (screenH * 0.1589) + 1, (screenW * 0.7725) + 1, (screenH * 0.1797) + 1, tocolor(0, 0, 0, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("1|0", screenW * 0.7246, screenH * 0.1589, screenW * 0.7725, screenH * 0.1797, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawRectangle(screenW * 0.7832, screenH * 0.0924, screenW * 0.2070, screenH * 0.0534, tocolor(1, 1, 1, 197), false)
        dxDrawImage(807, 76, 30, 26, ":Hud/img/10.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawRectangle(screenW * 0.8271, screenH * 0.1120, screenW * 0.0605, screenH * 0.0143, tocolor(129, 130, 0, 197), false)
        dxDrawRectangle(screenW * 0.8271, screenH * 0.1120, screenW * 0.0605, screenH * 0.0143, tocolor(233, 235, 0, 254), false)
        dxDrawImage(914, 79, 27, 23, ":Hud/img/17.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawRectangle(screenW * 0.9248, screenH * 0.1120, screenW * 0.0605, screenH * 0.0143, tocolor(2, 180, 232, 162), false)
        dxDrawRectangle(screenW * 0.9248, screenH * 0.1120, screenW * 0.0605, screenH * 0.0143, tocolor(1, 174, 225, 254), false)
        dxDrawRectangle(screenW * 0.7822, screenH * 0.1549, screenW * 0.0918, screenH * 0.0378, tocolor(0, 0, 0, 194), false)
        dxDrawText("Oxigenio:"..Oxigenio.."%", screenW * 0.7813, screenH * 0.1576, screenW * 0.8740, screenH * 0.1927, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
        dxDrawText("R$"..dinheiro.., screenW * 0.7813, screenH * 0.2018, screenW * 0.9688, screenH * 0.2227, tocolor(53, 251, 0, 194), 2.00, "default-bold", "left", "top", false, false, false, false, false)
    end
)
addEventHandler( "onClientRender", getRootElement(), hud )

 

Edited by DNL291
Use o botão para o código Lua da próxima vez
Link to comment
40 minutes ago, Eficiencia said:

oi, sou novo na area de programaçao em .lua e fazer paineis dx.

bom resolvi fazer uma hud, o mta reconhece o script mas a hud na aparece quando executo o mesmo.

codigo:


local screenW, screenH = guiGetScreenSize()

    function hud ()

        local vida = getElementHealth ( localPlayer )
        local colete = getPedArmor ( localPlayer )
        local muniçao = getPedAmmoInClip ( localPlayer )
        local total = getPedTotalAmmo ( localPlayer )
        local Oxigenio = getPedOxygenLevel ( localPlayer )
        local dinheiro = getPlayerMoney ( localPlayer )
        local arma = gerPedWeapon ( localPlayer )

        local vidaatual = (screenW * 0.0889) * (vida/100)
        local coleteatual = (screenW * 0.0889) * (colete/100)

        dxDrawRectangle(screenW * 0.7148, screenH * 0.0000, screenW * 0.2852, screenH * 0.0859, tocolor(0, 0, 0, 193), false)
        dxDrawImage(screenW * 0.7246, screenH * 0.0195, screenW * 0.0381, screenH * 0.0430, ":Hud/img/22.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawRectangle(screenW * 0.7686, screenH * 0.0273, screenW * 0.0889, screenH * 0.0273, tocolor(173, 0, 0, 126), false)
        dxDrawRectangle(screenW * 0.7686, screenH * 0.0273, vidaatual, screenH * 0.0273, tocolor(173, 0, 0, 254), false)
        dxDrawImage(screenW * 0.8633, screenH * 0.0143, screenW * 0.0342, screenH * 0.0456, ":Hud/img/27.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawRectangle(screenW * 0.9014, screenH * 0.0273, screenW * 0.0889, screenH * 0.0273, tocolor(116, 116, 116, 141), false)
        dxDrawRectangle(screenW * 0.9014, screenH * 0.0273, coleteatual, screenH * 0.0273, tocolor(116, 116, 116, 254), false)
        dxDrawImage(screenW * 0.7207, screenH * 0.0859, screenW * 0.0576, screenH * 0.0716, ":Hud/armas/"..arma..".png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawText("1|0", (screenW * 0.7246) - 1, (screenH * 0.1589) - 1, (screenW * 0.7725) - 1, (screenH * 0.1797) - 1, tocolor(0, 0, 0, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("1|0", (screenW * 0.7246) + 1, (screenH * 0.1589) - 1, (screenW * 0.7725) + 1, (screenH * 0.1797) - 1, tocolor(0, 0, 0, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("1|0", (screenW * 0.7246) - 1, (screenH * 0.1589) + 1, (screenW * 0.7725) - 1, (screenH * 0.1797) + 1, tocolor(0, 0, 0, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("1|0", (screenW * 0.7246) + 1, (screenH * 0.1589) + 1, (screenW * 0.7725) + 1, (screenH * 0.1797) + 1, tocolor(0, 0, 0, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("1|0", screenW * 0.7246, screenH * 0.1589, screenW * 0.7725, screenH * 0.1797, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawRectangle(screenW * 0.7832, screenH * 0.0924, screenW * 0.2070, screenH * 0.0534, tocolor(1, 1, 1, 197), false)
        dxDrawImage(807, 76, 30, 26, ":Hud/img/10.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawRectangle(screenW * 0.8271, screenH * 0.1120, screenW * 0.0605, screenH * 0.0143, tocolor(129, 130, 0, 197), false)
        dxDrawRectangle(screenW * 0.8271, screenH * 0.1120, screenW * 0.0605, screenH * 0.0143, tocolor(233, 235, 0, 254), false)
        dxDrawImage(914, 79, 27, 23, ":Hud/img/17.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawRectangle(screenW * 0.9248, screenH * 0.1120, screenW * 0.0605, screenH * 0.0143, tocolor(2, 180, 232, 162), false)
        dxDrawRectangle(screenW * 0.9248, screenH * 0.1120, screenW * 0.0605, screenH * 0.0143, tocolor(1, 174, 225, 254), false)
        dxDrawRectangle(screenW * 0.7822, screenH * 0.1549, screenW * 0.0918, screenH * 0.0378, tocolor(0, 0, 0, 194), false)
        dxDrawText("Oxigenio:"..Oxigenio.."%", screenW * 0.7813, screenH * 0.1576, screenW * 0.8740, screenH * 0.1927, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
        dxDrawText("R$"..dinheiro.., screenW * 0.7813, screenH * 0.2018, screenW * 0.9688, screenH * 0.2227, tocolor(53, 251, 0, 194), 2.00, "default-bold", "left", "top", false, false, false, false, false)
    end
)
addEventHandler( "onClientRender", getRootElement(), hud ) 

 

 

Link to comment

Olá @Eficiencia, por favor, visite estes tópicos antes de postar qualquer coisa nesta seção;

Obviamente não vai funcionar, primeiro por que tem um parênteses fechando algo inexistente em sua linha 41, e segundo que seu código apresenta algumas falhas na identação. Cheque sempre o debug ;)

 

Link to comment
local screenW, screenH = guiGetScreenSize()
    
addEventHandler ("onClientRender", root, function ()
	local vida = getElementHealth ( localPlayer )
	local colete = getPedArmor ( localPlayer )
	local muniçao = getPedAmmoInClip ( localPlayer )
	local total = getPedTotalAmmo ( localPlayer )
	local Oxigenio = getPedOxygenLevel ( localPlayer )
	local dinheiro = getPlayerMoney ( localPlayer )
	local arma = gerPedWeapon ( localPlayer )
	local vidaatual = (screenW * 0.0889) * (vida/100)
	local coleteatual = (screenW * 0.0889) * (colete/100)
	--
	dxDrawRectangle(screenW * 0.7148, screenH * 0.0000, screenW * 0.2852, screenH * 0.0859, tocolor(0, 0, 0, 193), false)
	dxDrawImage(screenW * 0.7246, screenH * 0.0195, screenW * 0.0381, screenH * 0.0430, ":Hud/img/22.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
	dxDrawRectangle(screenW * 0.7686, screenH * 0.0273, screenW * 0.0889, screenH * 0.0273, tocolor(173, 0, 0, 126), false)
	dxDrawRectangle(screenW * 0.7686, screenH * 0.0273, vidaatual, screenH * 0.0273, tocolor(173, 0, 0, 254), false)
	dxDrawImage(screenW * 0.8633, screenH * 0.0143, screenW * 0.0342, screenH * 0.0456, ":Hud/img/27.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
	dxDrawRectangle(screenW * 0.9014, screenH * 0.0273, screenW * 0.0889, screenH * 0.0273, tocolor(116, 116, 116, 141), false)
	dxDrawRectangle(screenW * 0.9014, screenH * 0.0273, coleteatual, screenH * 0.0273, tocolor(116, 116, 116, 254), false)
	dxDrawImage(screenW * 0.7207, screenH * 0.0859, screenW * 0.0576, screenH * 0.0716, ":Hud/armas/"..arma..".png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
	dxDrawText("1|0", (screenW * 0.7246) - 1, (screenH * 0.1589) - 1, (screenW * 0.7725) - 1, (screenH * 0.1797) - 1, tocolor(0, 0, 0, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
	dxDrawText("1|0", (screenW * 0.7246) + 1, (screenH * 0.1589) - 1, (screenW * 0.7725) + 1, (screenH * 0.1797) - 1, tocolor(0, 0, 0, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
	dxDrawText("1|0", (screenW * 0.7246) - 1, (screenH * 0.1589) + 1, (screenW * 0.7725) - 1, (screenH * 0.1797) + 1, tocolor(0, 0, 0, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
	dxDrawText("1|0", (screenW * 0.7246) + 1, (screenH * 0.1589) + 1, (screenW * 0.7725) + 1, (screenH * 0.1797) + 1, tocolor(0, 0, 0, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
	dxDrawText("1|0", screenW * 0.7246, screenH * 0.1589, screenW * 0.7725, screenH * 0.1797, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
	dxDrawRectangle(screenW * 0.7832, screenH * 0.0924, screenW * 0.2070, screenH * 0.0534, tocolor(1, 1, 1, 197), false)
	dxDrawImage(807, 76, 30, 26, ":Hud/img/10.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
	dxDrawRectangle(screenW * 0.8271, screenH * 0.1120, screenW * 0.0605, screenH * 0.0143, tocolor(129, 130, 0, 197), false)
	dxDrawRectangle(screenW * 0.8271, screenH * 0.1120, screenW * 0.0605, screenH * 0.0143, tocolor(233, 235, 0, 254), false)
	dxDrawImage(914, 79, 27, 23, ":Hud/img/17.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
	dxDrawRectangle(screenW * 0.9248, screenH * 0.1120, screenW * 0.0605, screenH * 0.0143, tocolor(2, 180, 232, 162), false)
	dxDrawRectangle(screenW * 0.9248, screenH * 0.1120, screenW * 0.0605, screenH * 0.0143, tocolor(1, 174, 225, 254), false)
	dxDrawRectangle(screenW * 0.7822, screenH * 0.1549, screenW * 0.0918, screenH * 0.0378, tocolor(0, 0, 0, 194), false)
	dxDrawText("Oxigenio:"..Oxigenio.."%", screenW * 0.7813, screenH * 0.1576, screenW * 0.8740, screenH * 0.1927, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
	dxDrawText("R$"..dinheiro.., screenW * 0.7813, screenH * 0.2018, screenW * 0.9688, screenH * 0.2227, tocolor(53, 251, 0, 194), 2.00, "default-bold", "left", "top", false, false, false, false, false)
end)

EDIT: Não testado.

Link to comment
2 hours ago, #DeltaSCR said:

Olá @Eficiencia, por favor, visite estes tópicos antes de postar qualquer coisa nesta seção;

Obviamente não vai funcionar, primeiro por que tem um parênteses fechando algo inexistente em sua linha 41, e segundo que seu código apresenta algumas falhas na identação. Cheque sempre o debug ;)

 

peço desculpa pelo formato errado. 

   Antes de pedir ajuda aqui tentei passar no debug mas ele nao alegou nenhum erro

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