Functions

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

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

function Notify(msg, type, time)
    if Config.Notify == "qb" then
        if type == "primary" then 
            QBCore.Functions.Notify(msg, "primary", time)
        end
        if type == "success" then
            QBCore.Functions.Notify(msg, "success", time)
        end
        if type == "error" then
            QBCore.Functions.Notify(msg, "error", time)
        end
    elseif Config.Notify == "okok" then
        if type == "primary" then 
            exports['okokNotify']:Alert('Notify', msg, time, 'inform', true)
        end
        if type == "success" then
            exports['okokNotify']:Alert('Notify', msg, time, 'success', true)
        end
        if type == "error" then
            exports['okokNotify']:Alert('Notify', msg, time, 'error', true)
        end
    elseif Config.Notify == "ox" then
        if type == "primary" then
            lib.notify({ title = 'Notification', description = msg, type = 'inform' })
        elseif type == "error" then
            lib.notify({ title = 'Notification', description = msg, type = 'error' })
        elseif type == "success" then
           lib.notify({ title = 'Notification', description = msg, type = 'success' })
        end
    end
end

function CallCops(pCoords)
    if Config.Dispatch == 'cd_dispatch' then
        local data = exports['cd_dispatch']:GetPlayerInfo()
        TriggerServerEvent('cd_dispatch:AddNotification', {
            job_table = {'police'},
            coords = data.coords,
            title = '10-10 - Delivery Drugs',
            message = 'A '..data.sex..' possibly committing a crime '..data.street,
            flash = 0,
            unique_id = tostring(math.random(0000000,9999999)),
            blip = {
                sprite = 156,
                scale = 1.2,
                colour = 1,
                flashes = false,
                text = '911 - Delivery Drugs',
                time = (5*60*1000),
                sound = 1,
            }
        })
    elseif Config.Dispatch == 'ps-dispatch' then
        exports["ps-dispatch"]:CustomAlert({
           coords = pCoords,
           message = "Delivery Drugs",
           dispatchCode = "911",
           description = "Delivery Drugs",
           radius = 0,
           sprite = 357,
           color = 3,
           scale = 0.8,
           length = 3,
        })
    elseif Config.Dispatch == "core_dispatch" then
        exports['core_dispatch']:addCall("20-12", "Vehicle is being stolen", { {},{}, { pCoords }, "police", 3000, 11, 5 } ) 
    end
end

function CheckPlayer()
    local playerPed = PlayerPedId()
    if IsEntityDead(playerPed) or IsPedSwimming(playerPed) or IsPedSittingInAnyVehicle(playerPed) then
        return false
    else
        return true
    end
end

function SendEmail()
    TriggerServerEvent("qb-phone:server:sendNewMail", {
        sender = "Mr. Nobody",
        subject = "The Job",
        message = "Take this box to the waypoint marked on your GPS. \nWatch out, the police have been alerted!",
    })
end

Last updated