Advertisement
glitchdetector

Minimap Anchor v2.0

Sep 13th, 2018
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.88 KB | None | 0 0
  1. local isRadarExtended = false
  2. Citizen.CreateThread(function()
  3.     local held_timer = 0
  4.     while true do
  5.         Wait(20)
  6.         -- extend minimap on keypress
  7.         if IsControlPressed( 0, 20 ) then
  8.             held_timer = held_timer + 1
  9.             if held_timer == 15 then
  10.                 if not isRadarExtended then
  11.                     PlaySoundFrontend(-1, "CONTINUE", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1)
  12.                     SetRadarBigmapEnabled( true, false )
  13.                     isRadarExtended = true
  14.                 else
  15.                     PlaySoundFrontend(-1, "EXIT", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1)
  16.                     SetRadarBigmapEnabled( false, false )
  17.                     isRadarExtended = false
  18.                 end
  19.             end
  20.         else
  21.             held_timer = 0
  22.         end
  23.     end
  24. end)
  25.  
  26. function GetMinimapAnchor()
  27.     -- Safezone goes from 1.0 (no gap) to 0.9 (5% gap (1/20))
  28.     -- 0.05 * ((safezone - 0.9) * 10)
  29.     local safezone = GetSafeZoneSize()
  30.     local safezone_x = 1.0 / 20.0
  31.     local safezone_y = 1.0 / 20.0
  32.     local aspect_ratio = GetAspectRatio(0)
  33.     local res_x, res_y = GetActiveScreenResolution()
  34.     local ultra_wide = (aspect_ratio > 2.3)
  35.     local xscale = 1.0 / res_x
  36.     local yscale = (1.0 / res_y)
  37.     local Minimap = {}
  38.     if IsRadarEnabled() and not IsRadarHidden() then
  39.         if isRadarExtended then
  40.             Minimap.width = xscale * (res_x / (2.52 * aspect_ratio))
  41.             Minimap.height = yscale * (res_y / 2.438)
  42.         else
  43.             Minimap.width = xscale * (res_x / (4 * aspect_ratio))
  44.             Minimap.height = yscale * (res_y / 5.674)
  45.         end
  46.         if not ultra_wide then
  47.             Minimap.left_x = xscale * (res_x * (safezone_x * ((math.abs(safezone - 1.0)) * 10)))
  48.         else
  49.             if aspect_ratio < 2.4 then
  50.                 Minimap.left_x = 0.1185 + (xscale * (res_x * (safezone_x * ((math.abs(safezone - 1.0)) * 10))))
  51.             elseif aspect_ratio < 5.4 then
  52.                 Minimap.left_x = 0.1185 + (xscale * (res_x * (safezone_x * ((math.abs(safezone - 1.0)) * 10))))
  53.             else
  54.                 Minimap.left_x = xscale * (res_x * (safezone_x * ((math.abs(safezone - 1.0)) * 10)))
  55.             end
  56.         end
  57.         Minimap.bottom_y = 1.0 - yscale * (res_y * (safezone_y * ((math.abs(safezone - 1.0)) * 10)))
  58.         Minimap.right_x = Minimap.left_x + Minimap.width
  59.         Minimap.top_y = Minimap.bottom_y - Minimap.height
  60.         Minimap.x = Minimap.left_x
  61.         Minimap.y = Minimap.top_y
  62.         Minimap.xunit = xscale
  63.         Minimap.yunit = yscale
  64.     else
  65.         Minimap.width = -1.0
  66.         Minimap.height = -1.0
  67.         Minimap.left_x = -1.0
  68.         Minimap.bottom_y = -1.0
  69.         Minimap.right_x = -1.0
  70.         Minimap.top_y = -1.0
  71.         Minimap.x = -1.0
  72.         Minimap.y = -1.0
  73.         Minimap.xunit = -1.0
  74.         Minimap.yunit = -1.0
  75.     end
  76.     return Minimap
  77. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement