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.

esx.lua

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

Citizen.CreateThreadNow(function()
    if Config.Framework == "esx" then
        while ESX == nil do
            ESX = exports["es_extended"]:getSharedObject()
        end
        while ESX.GetPlayerData().job == nil do
            Wait(10)
        end
    end
    PlayerData = ESX.GetPlayerData()
    PlayerJob = PlayerData.job
    if Config.RequireJob then
        if Config.NewspaperDeliveryJob[PlayerData.job.name] then
            CanInteract = true
        else
            CanInteract = false
        end
    else
        CanInteract = true
    end
    Wait(100)
    CreateAllPeds()
    if CanInteract then
        if Config.EnableBlip then
            newspaperBlip = createBlip()
        end
    end
    if not Config.Target then
        CheckProximity()
    end
end)

RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)
    ESX.PlayerLoaded = true
    PlayerLoaded = true
    if CanInteract then
        if Config.EnableBlip then
            newspaperBlip = createBlip()
        end
    end
end)

RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', 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)

function TriggerServerCallback(name, cb, ...)
    ESX.TriggerServerCallback(name, cb, ...)
end

function SpawnVehicle(spawnCoords, heading)
    ESX.Game.SpawnVehicle(Config.VehicleModel, spawnCoords, heading, function(vehicle)
        SetVehicleModKit(vehicle, 0)
        Wait(100)
        if Config.SpawnInsideVehicle then
            local playerPed = PlayerPedId()
            SetPedIntoVehicle(playerPed, vehicle, -1)
        end
        local plate = GetVehicleNumberPlateText(vehicle)
        local model = GetDisplayNameFromVehicleModel(GetEntityModel(vehicle))
        AddVehiclekeys(model, plate, true)
        Wait(100)
        if Config.Fuel then
            Config.FuelExport:SetFuel(vehicle, 100.0)
        end
        currentVehicle = vehicle
    end)
end

function DeleteJobVehicle(vehicle)
    ESX.Game.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