Jump to content

IVHud-Vehicle Health?


Admigo

Recommended Posts

Heey all,

There is a resource called ivhud that has the hud of gta iv.

There is a green ring with health but how can i make it to vehicle health?

Codes:

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() 
    if raceMode and 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 
  

Pls Help.

Thanks Admigo.

Link to comment

First of all, that wasn't all of it.

Let me give you an example, how do you find out vehicle health?

I am in a vehicle, alright.

addCommandHandler("vhealth", 
     function(player, cmd) 
          local vehicle = getPedOccupiedVehicle(player) 
          if vehicle then 
               outputChatBox("Vehicle health: " .. tonumber(getElementHealth(vehicle)) .. ".", player, 220, 220, 0, false) 
          else 
               outputChatBox("You're not in a vehicle.", player, 255, 0, 0, false) 
          end 
     end 
) 

Try to use that for your edits on the HUD.

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