AWS DEVELOPMENT / DOCUMENTATION

Your server. Our expertise.

Everything you need to install, configure and build.

94 guides • 11 resources • Always here to help
About resource versions

These guides include the original resource names. Use the folder and SQL names supplied with your downloaded version. A renamed AWS package may differ from the original EXIT release.

qb.lua

if Config.Framework ~= "qb" then
    return
end

Citizen.CreateThreadNow(function()
    if Config.Framework == "qb" then
        QBCore = exports['qb-core']:GetCoreObject()
        while QBCore.Functions.GetPlayerData().job == nil do
            Wait(10)
        end
        PlayerData = QBCore.Functions.GetPlayerData()
        Wait(200)
        if Config.RequireJob then
            if Config.NewspaperDeliveryJob[PlayerData.job.name] then
                CanInteract = true
            else
                CanInteract = false
            end
        else
            CanInteract = true
        end
        CreateAllPeds()
        if CanInteract then
            if Config.EnableBlip then
                newspaperBlip = createBlip()
            end
        end
        if not Config.Target then
            CheckProximity()
        end
    end
end)

---@OnPlayerLoaded event for QBCore
AddEventHandler('QBCore:Client:OnPlayerLoaded', function(Player)
    Player = QBCore.Functions.GetPlayerData()
    if not Player then return Wait(1250) end
    PlayerData = Player
    PlayerJob = PlayerData.job
    PlayerLoaded = true
    if CanInteract then
        if Config.EnableBlip then
            newspaperBlip = createBlip()
        end
    end
    Wait(2000)
end)

---@OnJobUpdate event for QBCore
RegisterNetEvent('QBCore:Client:OnJobUpdate')
AddEventHandler('QBCore:Client:OnJobUpdate', function(job)
    PlayerData.job = job
    PlayerJob = job
    RemoveBlip(newspaperBlip)
    if Config.RequireJob then
        if Config.NewspaperDeliveryJob[PlayerData.job.name] then
            CanInteract = true
        else
            CanInteract = false
        end
    else
        CanInteract = true
    end
    if CanInteract then
        if Config.EnableBlip then
            newspaperBlip = createBlip()
        end
    end
end)

---@TriggerServerCallback event for QBCore.
function TriggerServerCallback(name, cb, ...)
    QBCore.Functions.TriggerCallback(name, cb, ...)
end

function SpawnVehicle(spawnCoords, heading)
    PlayerPed = PlayerPedId()
    QBCore.Functions.SpawnVehicle(Config.VehicleModel, function(vehicle)
        SetVehicleNumberPlateText(vehicle, "DEL" .. tostring(math.random(1000, 9999)))
        SetEntityHeading(vehicle, heading)
        SetVehicleEngineOn(vehicle, true, true)
        if Config.Fuel then
            Config.FuelExport:SetFuel(vehicle, 100.0)
        end
        local plate = QBCore.Functions.GetPlate(vehicle)
        local model = GetDisplayNameFromVehicleModel(GetEntityModel(vehicle))
        AddVehiclekeys(model, plate, true)
        Wait(100)
        if Config.SpawnInsideVehicle then
            local playerPed = PlayerPedId()
            SetPedIntoVehicle(playerPed, vehicle, -1)
        end
        currentVehicle = vehicle
    end, spawnCoords, true)
end

function DeleteJobVehicle(vehicle)
    QBCore.Functions.DeleteVehicle(vehicle)
end

function createBlip()
    local blip = AddBlipForCoord(Config.StartJob.ped.coords.x, Config.StartJob.ped.coords.y, Config.StartJob.ped.coords
        .z)
    SetBlipSprite(blip, Config.Blip.sprite)
    SetBlipDisplay(blip, 2)
    SetBlipScale(blip, Config.Blip.size)
    SetBlipColour(blip, Config.Blip.color)
    SetBlipAsShortRange(blip, true)
    BeginTextCommandSetBlipName("STRING")
    AddTextComponentString(Config.Blip.text)
    EndTextCommandSetBlipName(blip)
    return blip

end