glitchdetector icon

Minimap Anchor v2.0

glitchdetector | PRO | 09/13/18 04:09:28 PM UTC | 0 ⭐ | 612 👁️ | Never ⏰ | []
Lua |

2.88 KB

|

None

|

0 👍

/

0 👎

local isRadarExtended = false
Citizen.CreateThread(function()
    local held_timer = 0
    while true do
        Wait(20)
        -- extend minimap on keypress
        if IsControlPressed( 0, 20 ) then
            held_timer = held_timer + 1
            if held_timer == 15 then
                if not isRadarExtended then
                    PlaySoundFrontend(-1, "CONTINUE", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1)
                    SetRadarBigmapEnabled( true, false )
                    isRadarExtended = true
                else
                    PlaySoundFrontend(-1, "EXIT", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1)
                    SetRadarBigmapEnabled( false, false )
                    isRadarExtended = false
                end
            end
        else
            held_timer = 0
        end
    end
end)
 
function GetMinimapAnchor()
    -- Safezone goes from 1.0 (no gap) to 0.9 (5% gap (1/20))
    -- 0.05 * ((safezone - 0.9) * 10)
    local safezone = GetSafeZoneSize()
    local safezone_x = 1.0 / 20.0
    local safezone_y = 1.0 / 20.0
    local aspect_ratio = GetAspectRatio(0)
    local res_x, res_y = GetActiveScreenResolution()
    local ultra_wide = (aspect_ratio > 2.3)
    local xscale = 1.0 / res_x
    local yscale = (1.0 / res_y)
    local Minimap = {}
    if IsRadarEnabled() and not IsRadarHidden() then
        if isRadarExtended then
            Minimap.width = xscale * (res_x / (2.52 * aspect_ratio))
            Minimap.height = yscale * (res_y / 2.438)
        else
            Minimap.width = xscale * (res_x / (4 * aspect_ratio))
            Minimap.height = yscale * (res_y / 5.674)
        end
        if not ultra_wide then
            Minimap.left_x = xscale * (res_x * (safezone_x * ((math.abs(safezone - 1.0)) * 10)))
        else
            if aspect_ratio < 2.4 then
                Minimap.left_x = 0.1185 + (xscale * (res_x * (safezone_x * ((math.abs(safezone - 1.0)) * 10))))
            elseif aspect_ratio < 5.4 then
                Minimap.left_x = 0.1185 + (xscale * (res_x * (safezone_x * ((math.abs(safezone - 1.0)) * 10))))
            else
                Minimap.left_x = xscale * (res_x * (safezone_x * ((math.abs(safezone - 1.0)) * 10)))
            end
        end
        Minimap.bottom_y = 1.0 - yscale * (res_y * (safezone_y * ((math.abs(safezone - 1.0)) * 10)))
        Minimap.right_x = Minimap.left_x + Minimap.width
        Minimap.top_y = Minimap.bottom_y - Minimap.height
        Minimap.x = Minimap.left_x
        Minimap.y = Minimap.top_y
        Minimap.xunit = xscale
        Minimap.yunit = yscale
    else
        Minimap.width = -1.0
        Minimap.height = -1.0
        Minimap.left_x = -1.0
        Minimap.bottom_y = -1.0
        Minimap.right_x = -1.0
        Minimap.top_y = -1.0
        Minimap.x = -1.0
        Minimap.y = -1.0
        Minimap.xunit = -1.0
        Minimap.yunit = -1.0
    end
    return Minimap
end

Comments