Synthe1 Posted June 19, 2020 Share Posted June 19, 2020 Yo guys, i have problem with my hud. Before dmg After dmg 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
MrKAREEM Posted June 19, 2020 Share Posted June 19, 2020 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 1 Link to comment
Hexon Posted June 19, 2020 Share Posted June 19, 2020 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
MrKAREEM Posted June 19, 2020 Share Posted June 19, 2020 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
Hexon Posted June 19, 2020 Share Posted June 19, 2020 1 hour ago, MrKAREEM said: math.floor will returns a less value if the speed 100 it will display 99 I think math.floor better for HP displaying https://imgur.com/a/pXDBuVg Link to comment
#!_A7M8D Posted June 20, 2020 Share Posted June 20, 2020 math.ceil turns 1.6 into 2 math.floor removes the decimal 2.9 > 2 , 3.1 > 3 you can use what you want. Link to comment
MrKAREEM Posted June 20, 2020 Share Posted June 20, 2020 math.ceil (x) Returns the smallest integer larger than or equal to x. math.floor (x) Returns the largest integer smaller than or equal to x. both of them are better use what you need Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now