try this (tested)
addEventHandler ( "onClientRender", getRootElement(), function()
local Vehicle = getPedOccupiedVehicle(getLocalPlayer())
if Vehicle then
local Type = getVehicleType(Vehicle)
if Type == "Plane" or Type == "Helicopter" then
local x,y,z = getElementPosition (getLocalPlayer())
dxDrawText("ALT:", 707+2, 8+2, 773+2, 42+2, tocolor(0, 0, 0), 0.70, "bankgothic", "left", "top", false, false, true)
dxDrawText("ALT:", 707, 8, 773, 42, tocolor(67, 150, 39), 0.70, "bankgothic", "left", "top", false, false, true)
dxDrawText("" ..tostring(math.floor (z)).. "m",777+2, 10+2, 866+2, 42+2, tocolor(0, 0, 0), 0.70, "bankgothic", "left", "top", false, false, true)
dxDrawText("" ..tostring(math.floor (z)).. "m",777, 10, 866, 42, tocolor(67, 150, 39), 0.70, "bankgothic", "left", "top", false, false, true)
dxDrawImage(773+1, 4+1, 68+1, 34+1,"imgs/speeds.png", 0,0,0, tocolor(0, 0, 0))
dxDrawImage(773, 4, 68, 34,"imgs/speeds.png", 0,0,0, tocolor(67, 150, 39))
end
end
end)
function getElementSpeed(element,unit)
if (unit == nil) then unit = 0 end
if (isElement(element)) then
local x,y,z = getElementVelocity(element)
if (unit=="mph" or unit==1 or unit =='1') then
return math.floor((x^2 + y^2 + z^2) ^ 0.5 * 100)
else
return math.floor((x^2 + y^2 + z^2) ^ 0.5 * 100 * 1.609344)
end
else
return false
end
end