Jump to content

IVHud - Vehicle Health Not Right?


Admigo

Recommended Posts

Heey all,

I have the ivhud and now i fixed it so i changed the health bar into vehicle health bar.

But there is a problem,the bar is not good because when my bar is 75% of health my car explodes(car health 300 or something)

But how can i change it that if the bar is 100% the car explodes.

Code:

function refreshHP() 
    hp=getElementHealth(localP)*1.8/(1+math.max(getPedStat(localP,24)-569,0)/431) --hp conversion to 180 to be max 
    armor=getPedArmor(localP)*1.8 --todo stat dependance on armor 
end 
  
function drawHP() 
    vehicle = getPedOccupiedVehicle(localP)--i made this code,i dont know if its a problem 
    if vehicle then 
        hp=getElementHealth(vehicle)*0.18 
        armor=0 
    end 
    local degr=360 
    local hpTempCol 
    if hp<=18 then 
        local ticks=getTickCount()%600 
        local red=ticks<=300 and 0 or 200 
        hpTempCol=tocolor(red,0,0,255) 
    end 
    hpTempCol=hpTempCol or hpCol 
    dxDrawImage(x2,y2,l2,h2,'images/ring360.png',0,0,0,hpTempCol,false) 
    if armor~=0 then 
        degr=degr-hp 
        dxDrawImage(x2,y2,l2,h2,'images/ring180.png',math.max(0,degr-1.-- s8) -->,0,0,armorCol,false) 
        degr=degr-armor 
    else 
        degr=degr-hp*2 
    end 
    --if dmgcount~=0 then 
    local currprog=0 
    for n=0,6 do 
        local val=180/2^n 
        if math.ceil(val)<=degr then 
            degr=degr-val 
            dxDrawImage(x2,y2,l2,h2,'images/ring'..math.ceil(val)..'.png',val+currprog,0,0,black,false) 
            currprog=currprog+val 
            if degr>=360 then 
                break 
            end 
        end 
    end 
end 

How can i fix this?

Thanks Admigo

Link to comment

my bad, replace the few lines with this:

  
    if raceMode and vehicle then 
        hp=(getElementHealth(vehicle)-250)*0.24 
        armor=0 
    end 
  

and next time ask IVhud related question in IVhud topic, so i can see it.

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