Jump to content

Duvida com HUD


Recommended Posts

O valor máximo de vida e colete funcionam normal, mas o mínimo não
 

local screenW, screenH = guiGetScreenSize()

addEventHandler("onClientRender", root,
    function()
        local health = math.floor(getElementHealth(getLocalPlayer()))
        local armor = math.floor(getPedArmor(getLocalPlayer()))

        local hunger = getElementData(getLocalPlayer(),"hunger") or 0
        local thirst = getElementData(getLocalPlayer(),"sede") or 0

        dxDrawImage(screenW * 0.7661, screenH * 0.9222, screenW * 0.0151, screenH * 0.0269, ":[404]Hud/files/food.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawText(""..hunger.."%", screenW * 0.7812, screenH * 0.9231, screenW * 0.7995, screenH * 0.9500, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
        dxDrawImage(screenW * 0.8078, screenH * 0.9222, screenW * 0.0151, screenH * 0.0269, ":[404]Hud/files/water.png", 0, 0, 0, tocolor(255, 253, 253, 254), false)
        dxDrawText(""..thirst.."%", screenW * 0.8229, screenH * 0.9222, screenW * 0.8411, screenH * 0.9491, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
        dxDrawImage(screenW * 0.8755, screenH * 0.9333, screenW * 0.0229, screenH * 0.0398, ":[404]Hud/files/micOff.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawLine(screenW * 0.7396, screenH * 0.9491, screenW * 0.8703, screenH * 0.9481, tocolor(35, 35, 35, 254), 10, false)
        dxDrawLine(screenW * 0.7260, screenH * 0.9648, screenW * 0.8568, screenH * 0.9639, tocolor(35, 35, 35, 254), 10, false)
        dxDrawLine(screenW * 0.7448, screenH * 0.9509, screenW * 0.8755/100*armor, screenH * 0.9500, tocolor(93, 93, 93, 254), 8, false)
        dxDrawLine(screenW * 0.7312, screenH * 0.9667, screenW * 0.8620/100*health, screenH * 0.9657, tocolor(255, 37, 37, 254), 8, false)
        dxDrawImage(screenW * 0.7260, screenH * 0.9333, screenW * 0.0151, screenH * 0.0259, ":[404]Hud/files/armour.png", 0, 0, 0, tocolor(255, 253, 253, 255), false)
        dxDrawImage(screenW * 0.7109, screenH * 0.9500, screenW * 0.0151, screenH * 0.0259, ":[404]Hud/files/health.png", 0, 0, 0, tocolor(255, 253, 253, 254), false)
        dxDrawImage(screenW * 0.8755, screenH * 0.9343, screenW * 0.0229, screenH * 0.0398, ":[404]Hud/files/micOn.png", 0, 0, 0, tocolor(42, 96, 187, 255), false)
    end
)

quando o colete está abaixo de 86 ele passa a ir para trás do ponto inicial, em 0 ele vai p lateral oposta da tela

Edited by MTS_LoneWolf
Link to comment
  • Other Languages Moderators

Ah, vc está usando dxDrawLine em vez de DxDrawRectangle... dai ele funciona diferente. O dxDrawRectangle vc especifica o tamanho X e Y, enquanto que o dxDrawLine você especifica a posição X,Y inicial e X,Y final. Dai é mais complexo de ser feito.

--(Posição inicial)+((PosFinal-PosInicial)*(coisa/100))
(screenW * 0.7448) + ((screenW * 0.1307) * (armor/100)) -- Armor
(screenW * 0.7312) + ((screenW * 0.1307) * (health/100)) -- Health

Agora sim funciona. Já testei.

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