Guest User

Untitled

a guest
Nov 23rd, 2019
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.50 KB | None | 0 0
  1. -----------------------------------------------------------------------------------------------------------------------------------------
  2. -- Frk👑 - np_hud
  3. -----------------------------------------------------------------------------------------------------------------------------------------
  4.  
  5. local dir = { [0] = 'N', [90] = 'W', [180] = 'S', [270] = 'E', [360] = 'N'}
  6. local Period = "AM"
  7. local Hours = nil
  8. local Minutes = nil
  9. local ped = PlayerPedId()
  10. local pos = GetEntityCoords(ped)
  11. local rua, cross = GetStreetNameAtCoord(pos.x, pos.y, pos.z)
  12. local Zone = GetLabelText(GetNameOfZone(pos.x, pos.y, pos.z))
  13.  
  14. Citizen.CreateThread(function()
  15.     while true do
  16.         CheckClock()
  17.         Citizen.Wait(1000)
  18.     end
  19. end)
  20.  
  21. Citizen.CreateThread(function()
  22.     while true do
  23.         CheckPlayerPosition()
  24.         Citizen.Wait(1000)
  25.     end
  26. end)
  27.  
  28. Citizen.CreateThread(function()
  29.     while true do
  30.         Citizen.Wait(1)
  31.         local UI = GetMinimapAnchor()
  32.         local HP = GetEntityHealth(ped) / 200.0
  33.         local Armor = GetPedArmour(ped) / 100.0
  34.         local Stamina = GetPlayerSprintStaminaRemaining(PlayerId()) / 722.0
  35.         local Breath = GetPlayerUnderwaterTimeRemaining(PlayerId()) / 34.0
  36.         if Armor > 1.0 then Armor = 1.0 end
  37.  
  38.         drawRct(UI.Left_x, UI.Bottom_y - 0.017, UI.Width, 0.028, 0, 0, 0, 255) -- Black background
  39.         drawRct(UI.Left_x + 0.001 , UI.Bottom_y - 0.015, UI.Width - 0.002 , 0.009, 88, 88, 88, 200) -- HP background
  40.         drawRct(UI.Left_x + 0.001 , UI.Bottom_y - 0.015, (UI.Width -0.002) * HP , 0.009, 88, 212, 104, 200) -- HP bar
  41.         drawRct(UI.Left_x + 0.001 , UI.Bottom_y - 0.002, UI.Width - 0.002 , 0.009, 88, 88, 88, 200) -- Armor background
  42.        
  43.  
  44.         if Armor > 0.05 then
  45.             drawRct(UI.Left_x + 0.001 , UI.Bottom_y - 0.002, (UI.Width - 0.002) * Armor , 0.009, 51, 171, 249, 200) -- Armor bar
  46.         elseif IsPedSwimmingUnderWater(PlayerPedId()) then
  47.             drawRct(UI.Left_x + 0.001 , UI.Bottom_y - 0.002, (UI.Width - 0.002) * Breath , 0.009, 97, 217, 252, 200)
  48.             drawTxt(UI.Left_x + 0.056 , UI.Bottom_y - 0.008 , 0.23, "Breath", 255, 255, 255, 255, 8)
  49.         else
  50.             drawRct(UI.Left_x + 0.001 , UI.Bottom_y - 0.002, (UI.Width - 0.002) - Stamina , 0.009, 243, 214, 102, 200)
  51.         end
  52.  
  53.  
  54.         if IsPedInAnyVehicle(ped, false) then
  55.             local speed = math.floor(GetEntitySpeed(GetVehiclePedIsIn(ped, false)) * 2.236936)
  56.             DisplayRadar(true) -- Activates minimap
  57.             drawRct(UI.Left_x, UI.Bottom_y - 0.248 , UI.Width, 0.073, 0, 0, 0, 55)
  58.             drawTxt(UI.Left_x + 0.001 , UI.Bottom_y - 0.249, 0.55, Hours .. ":" .. Minutes .. " " .. Period, 255, 255, 255, 255, 8) -- Clock
  59.             drawTxt(UI.Left_x + 0.001 , UI.Bottom_y - 0.217 , 0.58, heading, 250, 218, 94, 255, 8) -- Heading
  60.             drawTxt(UI.Left_x + 0.023 , UI.Bottom_y - 0.216 , 0.3, GetStreetNameFromHashKey(rua), 255, 255, 255, 255, 8) -- Street
  61.             drawTxt(UI.Left_x + 0.023 , UI.Bottom_y - 0.199 , 0.25, Zone, 255, 255, 255, 255, 8) -- Area
  62.             drawTxt(UI.Left_x + 0.003 , UI.Bottom_y - 0.045 , 0.4, speed .. " MPH", 255, 255, 255, 255, 4) -- Speed
  63.             drawRct(UI.Left_x, UI.Bottom_y - 0.045 , UI.Width, 0.073, 0, 0, 0, 55)
  64.         else
  65.             DisplayRadar(false) -- Deactivates minimap
  66.             drawRct(UI.Left_x, UI.Bottom_y - 0.088 , UI.Width, 0.073, 0, 0, 0, 55) -- Background
  67.             drawTxt(UI.Left_x + 0.001 , UI.Bottom_y - 0.09 , 0.55, Hours .. ":" .. Minutes .. " " .. Period, 255, 255, 255, 255, 8) -- Clock
  68.             drawTxt(UI.Left_x + 0.002 , UI.Bottom_y - 0.059 , 0.58, heading, 250, 218, 94, 255, 8) -- Heading
  69.             drawTxt(UI.Left_x + 0.023 , UI.Bottom_y - 0.057 , 0.3, GetStreetNameFromHashKey(rua), 255, 255, 255, 255, 8) -- Street
  70.             drawTxt(UI.Left_x + 0.023 , UI.Bottom_y - 0.04 , 0.25, Zone, 255, 255, 255, 255, 8) -- Area
  71.         end
  72.  
  73.     end
  74. end)
  75.  
  76. function CheckClock()
  77.     Hours = GetClockHours()
  78.     if Hours > 12 then
  79.         Hours = Hours - 12
  80.         Period = "PM"
  81.     else
  82.         Period = "AM"
  83.     end
  84.     if Hours < 10 then Hours = "0" .. Hours end
  85.     Minutes = GetClockMinutes()
  86.     if Minutes < 10 then Minutes = "0" .. Minutes end
  87.     for k,v in pairs(dir)do
  88.         heading = GetEntityHeading(ped)
  89.         if(math.abs(heading - k) < 45)then
  90.             heading = v
  91.             break
  92.         end
  93.     end
  94. end
  95.  
  96. function CheckPlayerPosition()
  97.     pos = GetEntityCoords(ped)
  98.     rua, cross = GetStreetNameAtCoord(pos.x, pos.y, pos.z)
  99.     Zone = GetLabelText(GetNameOfZone(pos.x, pos.y, pos.z))
  100. end
  101.  
  102. function drawRct(x,y,Width,height,r,g,b,a)
  103.     DrawRect(x+Width/2,y+height/2,Width,height,r,g,b,a)
  104. end
  105.  
  106. function drawTxt(x,y,scale,text,r,g,b,a,font)
  107.     SetTextFont(font)
  108.     SetTextScale(scale,scale)
  109.     SetTextColour(r,g,b,a)
  110.     SetTextOutline()
  111.     SetTextEntry("STRING")
  112.     AddTextComponentString(text)
  113.     DrawText(x,y)
  114. end
  115.  
  116. function disableHud()
  117.     HideHudComponentThisFrame(6)
  118.     HideHudComponentThisFrame(7)   
  119.     HideHudComponentThisFrame(8)   
  120.     HideHudComponentThisFrame(9)
  121. end
  122.  
  123. function GetMinimapAnchor()
  124.     local safezone = GetSafeZoneSize()
  125.     local safezone_x = 1.0 / 20.0
  126.     local safezone_y = 1.0 / 20.0
  127.     local aspect_ratio = GetAspectRatio(0)
  128.     local res_x, res_y = GetActiveScreenResolution()
  129.     local xscale = 1.0 / res_x
  130.     local yscale = 1.0 / res_y
  131.     local Minimap = {}
  132.     Minimap.Width = xscale * (res_x / (4 * aspect_ratio))
  133.     Minimap.height = yscale * (res_y / 5.674)
  134.     Minimap.Left_x = xscale * (res_x * (safezone_x * ((math.abs(safezone - 1.0)) * 10)))
  135.     Minimap.Bottom_y = 1.0 - yscale * (res_y * (safezone_y * ((math.abs(safezone - 1.0)) * 10)))
  136.     Minimap.right_x = Minimap.Left_x + Minimap.Width
  137.     Minimap.top_y = Minimap.Bottom_y - Minimap.height
  138.     Minimap.x = Minimap.Left_x
  139.     Minimap.y = Minimap.top_y
  140.     Minimap.xunit = xscale
  141.     Minimap.yunit = yscale
  142.     return Minimap
  143. end
Add Comment
Please, Sign In to add comment