Hi
So, what i'm trying to accomplish is pretty simple but i can't seem to do it . I want to show a healthbar over other players' vehicles.
Anywat, I've made this simple script:
addEventHandler( "onClientRender", root,
function( thePlayer )
local vehicle = getPedOccupiedVehicle(thePlayer)
local x, y, z = getElementPosition( vehicle )
local sX, sY = getScreenFromWorldPosition( x, y, z )
local health = math.floor( getElementHealth( vehicle )/10)
local Rhealth = 50
local lineLength = 56 * ( health / 100 )
if health < 25 then
health = 0
else
math.floor( getElementHealth( vehicle )/10)
end
if isElementOnScreen( vehicle ) then
if sX then
dxDrawText( health, sX, sY )
dxDrawRectangle( sX-32, sY-82, 60, 14, tocolor( 0, 100, 0, 120 ) )
dxDrawRectangle( sX-30, sY-80, 56, 10, tocolor( 0, 220, 0, 120 ) )
dxDrawRectangle( sX-30, sY-80, lineLength, 10, tocolor( 0, 220, 0 ) )
end
end
end
)
But it doesn't act as any other floating health bar (that one witch is on top of every player's car). I can see my own car's bar but i can't see other's ones (same thing with other players)
So, can anyone can help me out fixing this script, or give me another fully working one
Thnx;