ThatGamerBlue2

Untitled

Feb 12th, 2020
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.07 KB | None | 0 0
  1. MeanSeaLevel = 0.5
  2.  
  3. Citizen.CreateThread(function()
  4.     while true do
  5.         Citizen.Wait(0)
  6.         local PlayerRef = GetPlayerPed(-1)
  7.         if (IsPedSittingInAnyVehicle(PlayerRef)) then
  8.             local PlaneRef = GetVehiclePedIsIn(PlayerRef, false)
  9.             local PlaneX, PlaneY, PlaneZ = table.unpack(GetEntityCoords(PlaneRef))
  10.             local Altitude = GetEntityHeight(PlaneRef, PlaneX, PlaneY, -MeanSeaLevel, true, true)
  11.             -- Basically the same as PlaneZ + MeanSeaLevel buuuuuuuuuuuuuuuut oh well
  12.             drawTxt("ALT (meters): " .. roundInt(Altitude, 1) .. " (feet): " .. roundInt(Altitude * 3.28084, 1))
  13.         else
  14.             drawTxt("ALT: No Data")
  15.         end
  16.     end
  17. end)
  18.  
  19. function roundInt(num, numDecimalPlaces)
  20.   local mult = 10^(numDecimalPlaces or 0)
  21.   return math.floor(num * mult + 0.5) / mult
  22. end
  23.  
  24. function drawTxt(text)
  25.     SetTextFont(0)
  26.     SetTextProportional(1)
  27.     SetTextScale(0.0, 0.3)
  28.     SetTextColour(255, 255, 255, 255)
  29.     SetTextDropshadow(0, 0, 0, 0, 255)
  30.     SetTextEdge(1, 0, 0, 0, 255)
  31.     SetTextDropShadow()
  32.     SetTextOutline()
  33.     SetTextEntry("STRING")
  34.     AddTextComponentString(text)
  35.     DrawText(0.005, 0.005)
  36. end
Add Comment
Please, Sign In to add comment