Admigo Posted February 28, 2012 Share Posted February 28, 2012 Heey all, I want to detect the vehicle health of a player. I need it for the ivhud. Pls Help. Thanks Admigo Link to comment
Kenix Posted February 28, 2012 Share Posted February 28, 2012 Vehicle health or player health? addCommandHandler( 'veh_health', function( ) if isPedInVehicle( localPlayer ) then local veh = getPedOccupiedVehicle( localPlayer ) if veh then outputChatBox( 'Vehicle health: ' .. tostring( math.floor( getElementHealth( veh ) ) ) ) end end end ) So it get vehicle health.( If you in vehicle ). cmd veh_health. Updated. Link to comment
Admigo Posted February 28, 2012 Author Share Posted February 28, 2012 This is 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() 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 How can i edit this for vehicle health? Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now