Jump to content

Need Help!!


UnG//Macaus

Recommended Posts

I use this on my HUD, but is from the top down.

I wanted it to be from the bottom up, does anyone know how to do this?

local screenW,screenH = guiGetScreenSize() 
local resW,resH = 1280,720 
local sW,sH =  (screenW/resW), (screenH/resH) 
local Health = getElementHealth (localPlayer) 
  
dxDrawRectangle(40*sW, 559.2*sH, 11*sW, 138*sH, tocolor(0, 0, 0, 80), false, false) 
dxDrawRectangle(40*sW, 559.2*sH, 11*sW, 138*sH/100*Health, tocolor(0, 255, 0, 240), false, false) 

:|

Link to comment

Try this:

local screenW,screenH = guiGetScreenSize() 
local resW,resH = 1280,720 
local sW,sH =  (screenW/resW), (screenH/resH) 
local maxHealth = getPedMaxHealth(localPlayer) 
local Health = getElementHealth (localPlayer) 
local maxH = 138 
local barY = 559.2 * sH 
local barHeight = ((maxH * sH) /maxHealth) * Health 
  
dxDrawRectangle(40*sW, barY, 11*sW, maxH*sH, tocolor(0, 0, 0, 80)) 
dxDrawRectangle(40*sW, barY + (maxH-barHeight), 11*sW, barHeight, tocolor(0, 255, 0, 240)) 
  
-- 
function getPedMaxHealth(ped) 
    -- Output an error and stop executing the function if the argument is not valid 
    assert(isElement(ped) and (getElementType(ped) == "ped" or getElementType(ped) == "player"), "Bad argument @ 'getPedMaxHealth' [Expected ped/player at argument 1, got " .. tostring(ped) .. "]") 
    -- Grab his player health stat. 
    local stat = getPedStat(ped, 24) 
    -- Do a linear interpolation to get how many health a ped can have. 
    -- Assumes: 100 health = 569 stat, 200 health = 1000 stat. 
    local maxhealth = 100 + (stat - 569) / 4.31 
    -- Return the max health. Make sure it can't be below 1 
    return math.max(1, maxhealth) 
end 

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