Jump to content

Vehicle health bar problem


zixxonx

Recommended Posts

Hi i have a small problem. Im drawing a 145px (it needs to be 145 to fit with my radar ;p) and the max veh health hp is 1000 ( i made it 100 by math), i made that bar:

dxDrawRectangle(posx3,posy3,carhealth/10 , height3,tocolor(0,180,0,250) ,false)  

its just going to create 100px bar and when i do

dxDrawRectangle(posx3,posy3,15*(carhealth/10) , height3,tocolor(0,180,0,250) ,false) 

The bar is showing good, but when my vehicle hp is very low (its firing) it still draw that 50px i added, is there any fix for that? :/ I really want it!

Link to comment

Car gets on fire when its health reached 250 or 200, I can't remember now. So if the health gets to 250 the vehicle gets on fire and the health is continuously going down, when it gets to 0 the vehicle explodes. That's why vehicles explode faster if you keep shooting the vehicle which is already on fire.

The fix for that is using 750 as max health.

local health = getElementHealth( veh ) - 250; 
local barLength = health / 750 * 100; -- this will give you percentage of car health (0-100) 
-- when barLength <= 0 then vehicle is on fire 

Link to comment
That's why vehicles explode faster if you keep shooting the vehicle which is already on fire.[/lua]

Are you entirely sure this is true? I seem to recall that when a car is on fire, ramming walls and such does not speed up the progress. However, I might be wrong or it could be that only shooting it damages it while on fire. :o

Link to comment
That's why vehicles explode faster if you keep shooting the vehicle which is already on fire.[/lua]

Are you entirely sure this is true? I seem to recall that when a car is on fire, ramming walls and such does not speed up the progress. However, I might be wrong or it could be that only shooting it damages it while on fire. :o

I am pretty sure that's how it works and even ramming walls should decrease vehicle health faster thus making it explode faster. Ramming walls doesn't do much damage to vehicles unless you hit them at high speed, try changing vehicle health to 250 when you're at high speed (~100) and hit any wall. You must have thrown grenades at vehicles, have you noticed that sometimes they explode right after grenade explosion and sometimes they are on fire and when another grenade explodes the vehicle explodes with it? That's because it depends how much health has left before grenade explosion and how close to the vehicle the grenade exploded, same with RPGs.

For test, draw a bar/line on screen of length corresponding to vehicle's health (high screen resolution recommended - width wider than 1000px), see if it goes down any faster when you hit a wall:

dxDrawRectangle( 0, 0, getElementHealth( getPedOccupiedVehicle( localPlayer ) ), 30, tocolor( 255, 0, 0 ) ); 

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