Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2019
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.83 KB | None | 0 0
  1. local dir = { [0] = 'N', [90] = 'W', [180] = 'S', [270] = 'E', [360] = 'N'}
  2. local Period = "AM"
  3. local Hours = nil
  4. local Minutes = nil
  5. local Cruising = false
  6. local SeatBelt = false
  7. local Colours = {
  8.     ["Blue"] = {51, 171, 240},
  9.     ["Green"] = {88, 212, 104},
  10.     ["LightBlue"] = {97, 217, 252},
  11.     ["Red"] = {254, 74, 76},
  12.     ["White"] = {255, 255, 255},
  13.     ["Yellow"] = {250, 218, 94}
  14. }
  15.  
  16. -- Settings --
  17. local TimeType = "American" -- "American" for 03:30 PM , "European" for 15:30
  18. local BarText = false
  19.  
  20. Citizen.CreateThread(function()
  21.     while true do
  22.         CheckClock()
  23.         CheckPlayerPosition()
  24.         Citizen.Wait(1000)
  25.     end
  26. end)
  27.  
  28. -- Main --
  29. Citizen.CreateThread(function()
  30.     while true do
  31.         Citizen.Wait(1)
  32.         local ped = PlayerPedId()
  33.         local UI = GetMinimapAnchor()
  34.         local HP = GetEntityHealth(ped) / 200.0
  35.         local Armor = GetPedArmour(ped) / 100.0
  36.         local Stamina = GetPlayerSprintStaminaRemaining(PlayerId()) / 722.0
  37.         local Breath = GetPlayerUnderwaterTimeRemaining(PlayerId()) / 34.0
  38.         if Armor > 1.0 then Armor = 1.0 end
  39.  
  40.         -- Backgrounds --
  41.         DrawBack(UI.Left_x, UI.Bottom_y - 0.017, UI.Width, 0.028, 0, 0, 0, 255)
  42.         DrawBack(UI.Left_x + 0.001 , UI.Bottom_y - 0.015, UI.Width - 0.002 , 0.009, 88, 88, 88, 200)
  43.         DrawBack(UI.Left_x + 0.001 , UI.Bottom_y - 0.002, UI.Width - 0.002 , 0.009, 88, 88, 88, 200)
  44.         -- HP, Armor, Breath and Stamina --
  45.         DrawBar(UI.Left_x + 0.001 , UI.Bottom_y - 0.015, (UI.Width -0.002) * HP , 0.009, Colours.Green, 200)
  46.         if BarText then DrawColourText(UI.Left_x + 0.058 , UI.Bottom_y - 0.019 , 0.20, "Health", Colours.White, 200, 8) end
  47.         if Armor > 0.05 then
  48.             DrawBar(UI.Left_x + 0.001, UI.Bottom_y - 0.002, (UI.Width - 0.002) * Armor , 0.009, Colours.Blue, 200)
  49.             if BarText then DrawColourText(UI.Left_x + 0.058, UI.Bottom_y - 0.007 , 0.20, "Armor", Colours.White, 200, 8) end
  50.         elseif IsPedSwimmingUnderWater(ped) then
  51.             DrawBar(UI.Left_x + 0.001, UI.Bottom_y - 0.002, (UI.Width - 0.002) * Breath , 0.009, Colours.LightBlue, 200)
  52.             if BarText then DrawColourText(UI.Left_x + 0.058, UI.Bottom_y - 0.007, 0.20, "Breath", Colours.White, 200, 8) end
  53.         elseif IsPedInAnyVehicle(ped, false) then else
  54.             DrawBar(UI.Left_x + 0.001 , UI.Bottom_y - 0.002, (UI.Width - 0.002) - Stamina , 0.009, Colours.Yellow, 200)
  55.             if BarText then DrawColourText(UI.Left_x + 0.056, UI.Bottom_y - 0.007 , 0.20, "Stamina", Colours.White, 200, 8) end
  56.         end
  57.  
  58.         if IsPedInAnyVehicle(ped, false) then
  59.             -- Backgrounds --
  60.             DrawBack(UI.Left_x, UI.Bottom_y - 0.215 , UI.Width, 0.038, 0, 0, 0, 55)
  61.             DrawBack(UI.Left_x, UI.Bottom_y - 0.045 , UI.Width, 0.031, 0, 0, 0, 55)
  62.             -- Vehicle Stuff! --
  63.             VehicleDamage = GetVehicleEngineHealth(GetVehiclePedIsIn(ped)) / 1000
  64.             if SeatBelt then
  65.                 DrawColourText(UI.Left_x + 0.060 , UI.Bottom_y - 0.045, 0.4, "BELT", Colours.Yellow, 255, 4)
  66.                 DisableControlAction(0, 75, true)
  67.                 DisableControlAction(27, 75, true)
  68.             end
  69.             local speed = math.floor(GetEntitySpeed(GetVehiclePedIsIn(ped, false)) * 2.236936)
  70.             DisplayRadar(true) -- Activates minimap
  71.             if VehicleDamage > 0.0 then
  72.                 DrawBar(UI.Left_x + 0.001 , UI.Bottom_y - 0.002, (UI.Width - 0.002) * VehicleDamage , 0.009, Colours.Red, 200)
  73.                 if BarText then DrawColourText(UI.Left_x + 0.047 , UI.Bottom_y - 0.007 , 0.20, "Engine Health", Colours.White, 200, 8) end
  74.             else
  75.                 DrawColourText(UI.Left_x + 0.046 , UI.Bottom_y - 0.007 , 0.20, "Engine Critical", Colours.Red, 150, 8)
  76.             end
  77.             if TimeType == "American" then -- Time positioning
  78.                 DrawColourText(UI.Left_x + 0.103, UI.Bottom_y - 0.045, 0.4, Hours .. ":" .. Minutes .. " " .. Period, Colours.White, 255, 4)
  79.             elseif TimeType == "European" then
  80.                 DrawColourText(UI.Left_x + 0.119, UI.Bottom_y - 0.045, 0.4, Hours .. ":" .. Minutes .. " " .. Period, Colours.White, 255, 4)
  81.             end
  82.             DrawColourText(UI.Left_x + 0.003 , UI.Bottom_y - 0.217, 0.55, heading, Colours.Yellow, 255, 8) -- Heading
  83.             DrawColourText(UI.Left_x + 0.023 , UI.Bottom_y - 0.216, 0.3, GetStreetNameFromHashKey(rua), Colours.White, 255, 8) -- Street
  84.             DrawColourText(UI.Left_x + 0.023 , UI.Bottom_y - 0.199, 0.25, Zone, Colours.White, 255, 8) -- Area
  85.             if not Cruising then
  86.                 DrawColourText(UI.Left_x + 0.003 , UI.Bottom_y - 0.045, 0.4, speed .. " MPH", Colours.White, 255, 4) -- Speed
  87.             else
  88.                 DrawColourText(UI.Left_x + 0.003 , UI.Bottom_y - 0.045, 0.4, speed .. " MPH", Colours.Yellow, 255, 4)
  89.             end
  90.         else
  91.             DisplayRadar(false) -- Deactivates minimap
  92.             DrawBack(UI.Left_x, UI.Bottom_y - 0.088 , UI.Width, 0.073, 0, 0, 0, 55) -- Background
  93.             DrawColourText(UI.Left_x + 0.001 , UI.Bottom_y - 0.09 , 0.55, Hours .. ":" .. Minutes .. " " .. Period, Colours.White, 255, 8) -- Clock
  94.             DrawColourText(UI.Left_x + 0.002 , UI.Bottom_y - 0.059 , 0.58, heading, Colours.Yellow, 255, 8) -- Heading
  95.             DrawColourText(UI.Left_x + 0.023 , UI.Bottom_y - 0.057 , 0.3, GetStreetNameFromHashKey(rua), Colours.White, 255, 8) -- Street
  96.             DrawColourText(UI.Left_x + 0.023 , UI.Bottom_y - 0.04 , 0.25, Zone, Colours.White, 255, 8) -- Area
  97.         end
  98.     end
  99. end)
  100.  
  101. -- Seatbelt / CruiseControl --
  102. Citizen.CreateThread(function()
  103.   local ResetTop = true
  104.   while true do
  105.     Citizen.Wait(1)
  106.     local playerPed = PlayerPedId()
  107.     if IsPedInAnyVehicle(playerPed, false) then
  108.         local vehicle = GetVehiclePedIsIn(playerPed,false)
  109.         if GetPedInVehicleSeat(vehicle, -1) == playerPed then
  110.           if ResetTop then
  111.             CurrentMaxSpeed = GetVehicleHandlingFloat(vehicle, "CHandlingData", "fInitialDriveMaxFlatVel")
  112.             SetEntityMaxSpeed(vehicle, CurrentMaxSpeed)
  113.             ResetTop = false
  114.           end
  115.           if IsControlJustReleased(0,29) then
  116.             if not SeatBelt then
  117.                 PlaySound(-1, "NAV", "HUD_AMMO_SHOP_SOUNDSET", 0, 0, 1)
  118.                 Wait(500)
  119.                 SeatBelt = true
  120.             else
  121.                 PlaySound(-1, "NAV", "HUD_AMMO_SHOP_SOUNDSET", 0, 0, 1)
  122.                 Wait(500)
  123.                 SeatBelt = false
  124.             end
  125.           end
  126.           if IsControlJustReleased(0,246) and Cruising then
  127.             Cruising = false
  128.             CurrentMaxSpeed = GetVehicleHandlingFloat(vehicle, "CHandlingData", "fInitialDriveMaxFlatVel")
  129.             SetEntityMaxSpeed(vehicle, CurrentMaxSpeed)
  130.           elseif IsControlJustReleased(0,246) and not Cruising then
  131.             CruiseSpeed = GetEntitySpeed(vehicle)
  132.             if CruiseSpeed > 11.0 then
  133.                 Cruising = true
  134.                 SetEntityMaxSpeed(vehicle, CruiseSpeed)
  135.                 CruiseSpeed = math.floor(CruiseSpeed * 2.23694 + 0.5)
  136.             end
  137.           end
  138.         else
  139.           SeatBelt = false
  140.           ResetTop = true
  141.         end
  142.     end
  143.   end
  144. end)
  145.  
  146.  
  147. function CheckClock()
  148.     Hours = GetClockHours()
  149.     if TimeType == "American" then
  150.         if Hours > 12 then
  151.             Hours = Hours - 12
  152.             Period = "PM"
  153.         else
  154.             Period = "AM"
  155.         end
  156.     elseif TimeType == "European" then
  157.         Period = ""
  158.     else
  159.         Period = ""
  160.     end
  161.     if Hours < 10 then Hours = "0" .. Hours end
  162.     Minutes = GetClockMinutes()
  163.     if Minutes < 10 then Minutes = "0" .. Minutes end
  164.     for k,v in pairs(dir)do
  165.         heading = GetEntityHeading(ped)
  166.         if(math.abs(heading - k) < 45)then
  167.             heading = v
  168.             break
  169.         end
  170.     end
  171. end
  172.  
  173. function CheckPlayerPosition()
  174.     pos = GetEntityCoords(ped)
  175.     rua, cross = GetStreetNameAtCoord(pos.x, pos.y, pos.z)
  176.     Zone = GetLabelText(GetNameOfZone(pos.x, pos.y, pos.z))
  177. end
  178.  
  179. function DrawBack(x,y,Width,height,r,g,b,a)
  180.     DrawRect(x+Width/2,y+height/2,Width,height,r,g,b,a)
  181. end
  182.  
  183. function DrawBar(x,y,Width,height,colour,a)
  184.     DrawRect(x+Width/2,y+height/2,Width,height,colour[1],colour[2],colour[3],a)
  185. end
  186.  
  187. function DrawColourText(x,y,scale,text,colour,a,font)
  188.     SetTextFont(font)
  189.     SetTextScale(scale,scale)
  190.     SetTextColour(colour[1],colour[2],colour[3],a)
  191.     SetTextOutline()
  192.     SetTextEntry("STRING")
  193.     AddTextComponentString(text)
  194.     DrawText(x,y)
  195. end
  196.  
  197. function disableHud()
  198.     HideHudComponentThisFrame(6)
  199.     HideHudComponentThisFrame(7)   
  200.     HideHudComponentThisFrame(8)   
  201.     HideHudComponentThisFrame(9)
  202. end
  203.  
  204. function GetMinimapAnchor()
  205.     local safezone = GetSafeZoneSize()
  206.     local safezone_x = 1.0 / 20.0
  207.     local safezone_y = 1.0 / 20.0
  208.     local aspect_ratio = GetAspectRatio(0)
  209.     local res_x, res_y = GetActiveScreenResolution()
  210.     local xscale = 1.0 / res_x
  211.     local yscale = 1.0 / res_y
  212.     local Minimap = {}
  213.     Minimap.Width = xscale * (res_x / (4 * aspect_ratio))
  214.     Minimap.height = yscale * (res_y / 5.674)
  215.     Minimap.Left_x = xscale * (res_x * (safezone_x * ((math.abs(safezone - 1.0)) * 10)))
  216.     Minimap.Bottom_y = 1.0 - yscale * (res_y * (safezone_y * ((math.abs(safezone - 1.0)) * 10)))
  217.     Minimap.right_x = Minimap.Left_x + Minimap.Width
  218.     Minimap.top_y = Minimap.Bottom_y - Minimap.height
  219.     Minimap.x = Minimap.Left_x
  220.     Minimap.y = Minimap.top_y
  221.     Minimap.xunit = xscale
  222.     Minimap.yunit = yscale
  223.     return Minimap
  224. end
  225.  
  226. function showHelpNotification(msg)
  227.     BeginTextCommandDisplayHelp("STRING")
  228.     AddTextComponentSubstringPlayerName(msg)
  229.     EndTextCommandDisplayHelp(0, 0, 1, -1)
  230. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement