Jump to content

Vehicle life percentuage


Musamba

Recommended Posts

If i use this code:

math.floor(100*(getElementHealth(vehicle)/1000)) 

When my vehicle is burning remains at 25% when should be at 0%, but when i'm not damaged it's at 100%

If i use this one:

math.floor(1000*(getElementHealth(vehicle)/100)) 

It's the same thing of the first one but whit 1 more 0: 25% = 250% - 100% = 1000%

Can someone help me?

Link to comment

If I remember correctly, vehicles start burning when their health reaches 250 and it gets to 0 as it burns. Once their health reaches 0 they explode. So you want to use 750 health instead.

Try this:

local actualHealth = getElementHealth(vehicle)-250; 
actualHealth = actualHealth > 0 and actualHealth or 0; -- if it's burning it will be 0 
math.floor(100*(actualHealth/750)) 

Link to comment

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