Functions

local QBCore = exports[Config.Core]:GetCoreObject()

RegisterNetEvent('m-GopostalHeist:Client:Notify')
AddEventHandler("m-GopostalHeist:Client:Notify", function(msg,type,time)
    Notify(msg,type,time)
end)

function Notify(msg, type, time)
    if Config.Notify == "standalone" then
        BeginTextCommandThefeedPost("STRING")
        AddTextComponentSubstringPlayerName(msg)
        EndTextCommandThefeedPostTicker(true, true)
    elseif Config.Notify == "qb" then
        QBCore.Functions.Notify(msg, type, time)
    elseif Config.Notify == "okok" then
        exports['okokNotify']:Alert('Radar', msg, 5000, type, true)
    elseif Config.Notify == "ox" then
        lib.notify({ title = 'Heist', description = msg, type = type })
    end
end

function AlertCops()
    if Config.PoliceSettings.Dispatch == 'ps-dispatch' then
        local coords = GetEntityCoords(PlayerPedId())
        exports["ps-dispatch"]:CustomAlert({
            coords = coords,
            message = "Go-Postal Robbery",
            dispatchCode = "10-31",
            description = "Robbery",
            radius = 1.0,
            sprite = 108,
            color = 1,
            scale = 0.7,
            length = 3,
        })
    elseif Config.PoliceSettings.Dispatch == 'cd_dispatch' then
        local data = exports['cd_dispatch']:GetPlayerInfo()
        TriggerServerEvent('cd_dispatch:AddNotification', {
            job_table = {'police'},
            coords = data.coords,
            title = '10-12 - Go-Postal Robbery',
            message = 'A '..data.sex..' robbing a bank at '..data.street,
            flash = 0,
            unique_id = tostring(math.random(0000000,9999999)),
            blip = { sprite = 108,  scale = 0.7,  colour = 1, flashes = false,  text = 'Go-Postal Robbery', time = (3*60*1000), sound = 1, }
        })
    elseif Config.PoliceSettings.Dispatch == 'qs-dispatch' then
        local pCoords = GetEntityCoords(PlayerPedId())
        TriggerServerEvent('qs-dispatch:server:CreateDiapatchCall', {
             job = 'police',
             callLocation = pCoords,
             callCode = {code = '911 - Go-Postal Robbery', snippet = '10-10 Go-Postal Robbery'},
             message = 'possibly committing a crime',
             flashes = 'Boolean',
             image = 'URL.png',
             blip = {
                sprite = 110,
                scale = 1.5,
                colour = 1,
                flashes = true,
                text = '10-10 Go-Postal Robbery',
                time = (6*60*1000),-- 6 minutes
            }
        })
    end
end

function OpenDoors(doorName)
    if Config.Doorlock == "qb-doorlock" then
        TriggerServerEvent('qb-doorlock:server:updateState', doorName, false, false, false, true, false, false)
    end
end

function HackingMinigame(callback)
    if Config.MinigameType == "ps-ui" then
        exports['ps-ui']:Circle(function(success)
            if success then
                callback(success)
            else
                Notify(Language["Notification"].minigameFailed, "error", 5000)
            end
        end, 2, 20)
    elseif Config.MinigameType == "bl_ui" then
        local success = exports.bl_ui:CircleProgress(1, 20)
        if success then
            callback(success)
        else
            Notify(Language["Notification"].minigameFailed, "error", 5000)
        end
    elseif Config.MinigameType == "ox_lib" then
        local success = lib.skillCheck({'easy', 'easy', {areaSize = 60, speedMultiplier = 2}, 'hard'}, {'w', 'a', 's', 'd'})
        if success then
            callback(success)
        else
            Notify(Language["Notification"].minigameFailed, "error", 5000)
        end
    end
end

Last updated