Jump to content

Problems with player health/max health


dam034

Recommended Posts

Posted

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

dam034

I'm developing a revolution for MTASA

Posted (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

yZ1ROTY.png?1

 

Source: getPedMaxHealth (useful function)

Edited by MrTasty

Previously known as MrTasty.

Posted (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 by MrTasty
  • Haha 1

Previously known as MrTasty.

Posted
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 :)

G6HYac9.jpg

I love rock/metal/pop but don't mind any other music genre except чалга...that thing sux 
I also love cars

PS I'm friendly

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