Jump to content

[Help] getElementHealth


Synthe1

Recommended Posts

Yo guys, i have problem with my hud.

Before dmg

N9JQCJ6.png

After dmg

FaLhAfb.png

 

My code:


	health = getElementHealth (getPedOccupiedVehicle(localPlayer))
	 			 
 	local health = (math.max(health - 250, 0)/750)*100

	  
	      dxDrawImage ( (x/nX)*screenWidth*13.2, (y/nY)*screenHeight*11.0, (x/nX)*screenWidth*1.1, (y/nY)*screenHeight*1, "circle.png",0,0,0,tocolor(255,255,255,200))
		  --dxDrawImage ( (x/nX)*screenWidth*13.55, (y/nY)*screenHeight*11.1, (x/nX)*screenWidth*0.4, (y/nY)*screenHeight*0.4, "heart1.png",0,0,0,tocolor(255,255,255,150))
		  
	     dxDrawText(""..health.."", 0.968*screenX, 1.50*screenY, 0.75104166666667*screenX, 0.26018518518519*screenY, tocolor(255, 255, 255, 150), 1.5, "defaut", "center", "center", false, false, true, false, false)

	  dxDrawText("HP",0.968*screenX, 1.55*screenY, 0.75104166666667*screenX, 0.26018518518519*screenY, tocolor(255, 255, 255, 150), 1.5, "defaut", "center", "center", false, false, true, false, false)
	  ---------------------------------------------------------------------------
	  
  	end
 
   end
 addEventHandler ( "onClientRender", root, hud )
	  ---------------------------------------------------------------------------

I have no idea how to fix it, can u help me please? 

Link to comment

	health = getElementHealth (getPedOccupiedVehicle(localPlayer))
	 			 
 	local health = (math.max(health - 250, 0)/750)*100

	  
	      dxDrawImage ( (x/nX)*screenWidth*13.2, (y/nY)*screenHeight*11.0, (x/nX)*screenWidth*1.1, (y/nY)*screenHeight*1, "circle.png",0,0,0,tocolor(255,255,255,200))
		  --dxDrawImage ( (x/nX)*screenWidth*13.55, (y/nY)*screenHeight*11.1, (x/nX)*screenWidth*0.4, (y/nY)*screenHeight*0.4, "heart1.png",0,0,0,tocolor(255,255,255,150))
		  
	     dxDrawText(""..math.ceil(health).."", 0.968*screenX, 1.50*screenY, 0.75104166666667*screenX, 0.26018518518519*screenY, tocolor(255, 255, 255, 150), 1.5, "defaut", "center", "center", false, false, true, false, false)

	  dxDrawText("HP",0.968*screenX, 1.55*screenY, 0.75104166666667*screenX, 0.26018518518519*screenY, tocolor(255, 255, 255, 150), 1.5, "defaut", "center", "center", false, false, true, false, false)
	  ---------------------------------------------------------------------------
	  
  	end
 
   end
 addEventHandler ( "onClientRender", root, hud )
	  ---------------------------------------------------------------------------

try this

  • Thanks 1
Link to comment
4 hours ago, MrKAREEM said:

	health = getElementHealth (getPedOccupiedVehicle(localPlayer))
	 			 
 	local health = (math.max(health - 250, 0)/750)*100

	  
	      dxDrawImage ( (x/nX)*screenWidth*13.2, (y/nY)*screenHeight*11.0, (x/nX)*screenWidth*1.1, (y/nY)*screenHeight*1, "circle.png",0,0,0,tocolor(255,255,255,200))
		  --dxDrawImage ( (x/nX)*screenWidth*13.55, (y/nY)*screenHeight*11.1, (x/nX)*screenWidth*0.4, (y/nY)*screenHeight*0.4, "heart1.png",0,0,0,tocolor(255,255,255,150))
		  
	     dxDrawText(""..math.ceil(health).."", 0.968*screenX, 1.50*screenY, 0.75104166666667*screenX, 0.26018518518519*screenY, tocolor(255, 255, 255, 150), 1.5, "defaut", "center", "center", false, false, true, false, false)

	  dxDrawText("HP",0.968*screenX, 1.55*screenY, 0.75104166666667*screenX, 0.26018518518519*screenY, tocolor(255, 255, 255, 150), 1.5, "defaut", "center", "center", false, false, true, false, false)
	  ---------------------------------------------------------------------------
	  
  	end
 
   end
 addEventHandler ( "onClientRender", root, hud )
	  ---------------------------------------------------------------------------

try this

I think replace math.ceil to math.floor because rounding down returning a little bit real information for the player (if the player HP is 99.32 then dxDrawText display 100 but if you use .floor then displaying 99 . I think my solution is a little bit exact)

Link to comment
58 minutes ago, Hexon said:

I think replace math.ceil to math.floor because rounding down returning a little bit real information for the player (if the player HP is 99.32 then dxDrawText display 100 but if you use .floor then displaying 99 . I think my solution is a little bit exact)

math.floor will returns a less value if the speed 100 it will display 99 ?

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