Functions

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

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

function SendHelpText(msg, position)
    if Config.HelpText == "qb" then
        exports['qb-core']:DrawText(msg, position)
    elseif Config.HelpText == "okok" then
        exports['okokTextUI']:Open(msg, 'lightblue', position)
    end
end

function RemoveHelpText()
    if Config.HelpText == "qb" then
        exports['qb-core']:HideText()
    elseif Config.HelpText == "okok" then
        exports['okokTextUI']:Close()
    end
end

function SetVehicleFuel(vehicle, fuel)
    if Config.Fuel == "LegacyFuel" then
        exports["LegacyFuel"]:SetFuel(vehicle, 100.0)
    elseif Config.Fuel == "okokFuel" then
        exports['okokGasStation']:SetFuel(vehicle, 100.0)
    elseif Config.Fuel == "ox_fuel" then
        SetVehicleFuelLevel(vehicle, 100.0)
    elseif Config.Fuel == "ti_fuel" then
        exports["ti_fuel"]:setFuel(vehicle, 100.0, "RON91")
    elseif Config.Fuel == "qs-fuel" then
        exports['qs-fuelstations']:SetFuel(vehicle, 100.0)
    end
end

function GetFuelLevel(vehicle)
    if Config.FuelSystem == "LegacyFuel" then
        exports["LegacyFuel"]:GetFuel(vehicle)
    end
end

function GiveKeys(vehicle)
    local plate = GetVehicleNumberPlateText(vehicle)
    local model = GetDisplayNameFromVehicleModel(GetEntityModel(vehicle))
    if Config.VehicleKeys == "qb" then
        TriggerEvent("vehiclekeys:client:SetOwner", plate)
    elseif Config.VehicleKeys == "qs" then
        exports['qs-vehiclekeys']:GiveKeys(plate, model)
    elseif Config.VehicleKeys == "renewed" then
        exports['Renewed-Vehiclekeys']:addKey(plate)
    end
end

function GetVehicleName(hash)
    name = GetDisplayNameFromVehicleModel(hash)
    return name
end

function Minigame(callback)
    if Config.MinigameType == "ps-ui" then
        exports['ps-ui']:Circle(function(success)
            if success then
                callback(success)
            else
                Notify("You failed the minigame!", "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("You failed the minigame!", "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("You failed the minigame!", "error", 5000)
        end
    end
end

function SendEmail(sender, subject, message)
    if Config.Emails.phone == "qb-phone" then
        TriggerServerEvent("qb-phone:server:sendNewMail", {
            sender = sender,
            subject = subject,
            message = message,
        })
    elseif Config.Emails.phone == "qs-smartphone" then
        TriggerServerEvent("qs-smartphone:server:sendNewMail", {
            sender = sender,
            subject = subject,
            message = message,
        })
    elseif Config.Emails.phone == "gksphone" then
        TriggerServerEvent("gksphone:NewMail", {
            sender = sender,
            subject = subject,
            message = message,
         })
    elseif Config.Emails.phone == "yseries" then
        exports["yseries"]:SendNotification({
            app = 'email',
            title = subject,
            text = message,
            timeout = 3500,
            icon = 'https://cdn-icons-png.flaticon.com/128/10125/10125166.png',
        }, source,  sender)
    end
end

function MakeAnimation(animation)
    if Config.EmoteSystem == "dpemotes" then
        TriggerEvent('animations:client:EmoteCommandStart', {animation})
    elseif Config.EmoteSystem == "rpemotes" then
        exports["rpemotes"]:EmoteCommandStart(animation)
    elseif Config.EmoteSystem == "scully_emotemenu" then
        exports["scully_emotemenu"]:playEmoteByCommand(animation)
    end
end

function CancelAnimation(animation)
    if Config.EmoteSystem == "dpemotes" then
        TriggerEvent('animations:client:EmoteCommandStart', {"c"})
    elseif Config.EmoteSystem == "rpemotes" then
        exports["rpemotes"]:EmoteCommandStart("c")
    elseif Config.EmoteSystem == "scully_emotemenu" then
        exports["scully_emotemenu"]:cancelEmote()
    end
end

Last updated