Jump to content

Progress Bar [how to do]


[XGN]Razor

Recommended Posts

Im doing right now a bar and i have this problem: when the health is 100% works perfectly, but when the health is < 100, like 50 or 25, goes to the left side, this is the code:

addEventHandler ("onClientResourceStart",getResourceRootElement(getThisResource()), 
function() 
  sx,sy = guiGetScreenSize () 
  healthx = sx/800*5 
  healthy = sy/600*500 
  healthxoverlay = sx/800*6.55 
  healthyoverlay = sy/600*502 
  
  showPlayerHudComponent ("health",false) 
  counter = 0 
  normalhealthbar = false 
end) 
  
  
function render() 
      if (counter == 50) then 
        counter = 0 
      end 
      local healthRelative = getElementHealth(getLocalPlayer())/100 
            dxDrawImage (healthx, healthy, 150, 20, "hpempty.png",90) 
        dxDrawImageSection (healthxoverlay, healthyoverlay, 145*healthRelative, 13,0,0,healthxoverlay,healthyoverlay,"hpfull.png",90) 
    if (isPedInVehicle (getLocalPlayer())) then 
      local healthRelative = getElementHealth(getPedOccupiedVehicle(getLocalPlayer()))/1000 
      dxDrawImage (vehiclehealthx, vehiclehealthy, 76, 12, "hpempty.png") 
      end 
end 
addEventHandler ("onClientRender",getRootElement(),render) 
  

where is the problem?

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