dam034 Posted September 29, 2017 Share Posted September 29, 2017 Dear users, I'm trying to set via scripting the player's max health and health. I execute these commands: setPedStat(me, 24, 1000) setElementHealth(me, 1000) But when I try to retrieve my ped's current health, I get 200, also if the health's progress bar is full. Is this a bug? Or I done a mistake? Thanks Link to comment
Addlibs Posted September 29, 2017 Share Posted September 29, 2017 (edited) It's capped at 200 because that's the maximum health a ped/player can have at max-health skill level 100. Here is the actual equation for the max health: maxhealth = 100 + (stat - 569) / 4.31 Source: getPedMaxHealth (useful function) Edited September 29, 2017 by MrTasty Link to comment
dam034 Posted September 29, 2017 Author Share Posted September 29, 2017 Yes, can you explain me what means 4.31? Thanks Link to comment
Addlibs Posted September 29, 2017 Share Posted September 29, 2017 (edited) 4.31 is the gradient of the graph. I.e., the amount of stat difference between max health of 100 (stat value 569) and 200 (stat value 100) is 431. Difference between 100 and 200 is 100. 431/100 = 4.31. For every 4.31 units of increase in stat above the default of 569, you get extra 1 health point above 100. Shoulda paid attention in math class Edited September 29, 2017 by MrTasty 1 Link to comment
dam034 Posted September 29, 2017 Author Share Posted September 29, 2017 Thanks for the explanation. I have another question: why this? return math.max(1, maxhealth) Thanks Link to comment
koragg Posted September 29, 2017 Share Posted September 29, 2017 4 hours ago, dam034 said: Thanks for the explanation. I have another question: why this? return math.max(1, maxhealth) Thanks As stated in the wiki page: -- Return the max health. Make sure it can't be below 1 It means that if the value of 'maxhealth' is negative it will always return 1. Basically it checks to see which of the two values is bigger than the other and always returns the bigger one 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