Karuzo Posted March 6, 2014 Posted March 6, 2014 Hey Guys, so i wanted to make a progressbar which shows the current health in %. I have the progressbar already. Just dunno how to convert the health in %. Regards, KRZO.
glowdemon1 Posted March 6, 2014 Posted March 6, 2014 (edited) getElementHealth() returns a float between 0-1000. So you'll want to divide that by 10 and probably want to use math.ceil since you're gonna get results of 75.4571 etc. But decimal values shouldn't be a problem when working with progress bars, only if you're displaying this number somewhere, it'd be a PITA to read 85.7941. getElementHealth() math.ceil Edited March 6, 2014 by Guest
Saml1er Posted March 6, 2014 Posted March 6, 2014 Maths! Health = 50 Health = tonumber (Health) / 100 * 100 print ( Health.."%") -- 50 % As much as I know total health should be 100 or check it by yourself
K4stic Posted March 6, 2014 Posted March 6, 2014 Maths! Health = 50 Health = tonumber (Health) / 100 * 100 print ( Health.."%") -- 50 % As much as I know total health should be 100 or check it by yourself Health = tonumber (Health) / 100 * 100 <= realy? :3 why even need /100 * 100 lol just useless stuff
pa3ck Posted March 6, 2014 Posted March 6, 2014 Maths! Health = 50 Health = tonumber (Health) / 100 * 100 print ( Health.."%") -- 50 % As much as I know total health should be 100 or check it by yourself Health = tonumber (Health) / 100 * 100 <= realy? :3 why even need /100 * 100 lol just useless stuff Lol? Do you even know what you are talking about? Let's say I have 100HP. 100 / 100 = 1, so I have 1%?
Castillo Posted March 6, 2014 Posted March 6, 2014 getElementHealth() returns a float between 0-1000. So you'll want to divide that by 10 and probably want to use math.ceil since you're gonna get results of 75.4571 etc. But decimal values shouldn't be a problem when working with progress bars, only if you're displaying this number somewhere, it'd be a PITA to read 85.7941. getElementHealth() math.ceil Wrong, the player health is between 0 and 100, if you have the health stat, it can be maximum 200%, the vehicle health is between 0 and 1000.
manawydan Posted March 6, 2014 Posted March 6, 2014 you can use math.percent function to return percent. https://wiki.multitheftauto.com/wiki/Math.percent
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