.:HyPeX:. Posted December 27, 2014 Posted December 27, 2014 Well i'm totally confused and i'm not sure how to continue this.. I'll try to explain my best what is the issue: Vehicles have max 1000HP. Under 250HP they get into fire. I'm making a Health bar. Under 250HP it should be actually 0. Whats my issue? My maths to draw the bar. My fast-fix was to get down those 250HP. Health = health-250 max = 750 local progress = Health/max The problem is, if you had 500HP. Aka 50%, on the new calculation you would have 250/750, wich doesnt shows 50%, and i'm not sure how to do this... local health = math.ceil( ( getElementHealth(veh) )) local max = 1000 local min = 0 local percentage = health/max if health >= 250 then health = health-250 max = 750 progress = health / max else progress = health / max end if health <= 0 then health = 0 end Greetz EDIT: I'm an idiot, didnt realize that actually 0.33 is right if you have 250HP of 750.. My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
MTA Team botder Posted December 27, 2014 MTA Team Posted December 27, 2014 You should try the math functions. local nHealth = getElementHealth(veh) or 0 local nProgress = math.max(0, (nHealth - 250) / 750) OR local nHealth = math.max(0, (getElementHealth(veh) or 0) - 250) local nProgress = nHealth / 750 GitHub: Debug Console • MTA-Discord Relay Scripting: How to draw a line chart with DirectX functions? • Doppler Effect in MTA • Get the client's FPS • Customizable Blur Shader
Blinker. Posted December 27, 2014 Posted December 27, 2014 viewtopic.php?f=91&t=82700&p=754037#p754037
.:HyPeX:. Posted December 27, 2014 Author Posted December 27, 2014 EDIT: I'm an idiot, didnt realize that actually 0.33 is right if you have 250HP of 750.. My ingame nick is ~HyPeX~ BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager
Recommended Posts