function drawNeedle()
if not isPedInVehicle(g_Player) then
-- Fallback for player exiting car without onClientVehicleStartExit event
-- (e.g. falling off a bike)
hideSpeedometer()
end
local vehSpeed = getVehicleSpeed()
--local vehHealth = getElementHealth(source,getPedOccupiedVehicle(g_Player))
if vehHealth and (vehHealth > 0) then
-- Show a little red/green health bar on the speedo
local hp = (vehHealth-250)/750
local curBarLen = hp*g_BarW
if curBarLen < 1 then curBarLen = 1 end
local r = 255*(1 - hp)/0.5
if r > 255 then r = 255 end
local g = 255*hp/0.5
if g > 255 then g = 255 end
if g < 0 then g = 0 end
if hp >= 0 then
g_tFireStart = nil
dxDrawRectangle(x + g_ImageW/2 - g_BarW/2, y + g_BarYOffset, curBarLen, g_BarH, tocolor(r, g, 0, c_BarAlpha))
else
if not g_tFireStart then g_tFireStart = getTickCount() end
...