FiveM Docs
Guides

Using ox_target with ESX Legacy

Integrate ox_target with ESX Legacy using job restrictions, addBoxZone and server-validated interactions, with a full FiveM fxmanifest and troubleshooting guide.

ox_target works with ESX Legacy. It provides a third-eye interaction interface for NPCs, vehicles, objects and zones. The maintained ox_target source includes an ESX bridge, so its groups filter can use ESX job names and minimum grades.

Installation and resource order

Install the maintained ox_lib and ox_target releases, then ensure they start before your script. Keep the ESX core and database dependencies configured as described in Install ESX.

server.cfg
ensure oxmysql
ensure ox_lib
ensure esx_lib
ensure es_extended
ensure ox_target
ensure my_delivery

For a resource using both ESX server APIs and ox_target client exports:

fxmanifest.lua
fx_version 'cerulean'
game 'gta5'

shared_script '@es_extended/imports.lua'
client_script 'client.lua'
server_script 'server.lua'
dependencies { 'es_extended', 'ox_target' }

The ox_target resource depends on ox_lib; do not confuse ox_lib with ESX's own esx_lib.

Example — create a job-restricted target zone

This client example creates a police-only pickup interaction near a station. Replace the coordinates with your own locations.

client.lua
exports.ox_target:addBoxZone({
    name = 'police_supply_counter',
    coords = vec3(441.0, -981.0, 30.7),
    size = vec3(1.5, 1.2, 1.5),
    rotation = 0,
    debug = false,
    options = {
        {
            name = 'police_collect_supply',
            icon = 'fa-solid fa-box',
            label = 'Collect supplies',
            groups = { police = 0 },
            distance = 2.0,
            serverEvent = 'my_delivery:collectSupply',
        },
    },
})

The groups setting filters visible options in the client UI. It does not authorize the server action.

Validate the interaction on the server

A malicious client can send a server event without using the target interface. Verify the player, job, distance, item capacity and any cooldowns on the server. Never accept a client-submitted item name, price or quantity.

server.lua
local counter = vector3(441.0, -981.0, 30.7)

RegisterNetEvent('my_delivery:collectSupply', function()
    local playerId = source
    local xPlayer = ESX.GetPlayerFromId(playerId)
    if not xPlayer or xPlayer.getJob().name ~= 'police' then return end

    local ped = GetPlayerPed(playerId)
    if ped == 0 then return end
    if #(GetEntityCoords(ped) - counter) > 3.0 then return end

    -- Add an application-specific cooldown and stock check here.
    -- Only grant a configured item that exists in your inventory.
    if xPlayer.canCarryItem('water', 1) then
        xPlayer.addInventoryItem('water', 1)
    end
end)

This demonstration checks job and distance but intentionally leaves out production cooldown and stock management. Implement those before using it in a live economy.

Common ox_target exports

Client APIUse
addBoxZone / addSphereZoneInteract with a 3D area
addModelInteract with all objects or vehicles of a model
addLocalEntityInteract with a local entity handle
addEntityInteract with a network ID
addGlobalVehicleAdd an option to all vehicles
removeZone / removeModelClean up interactions when they are no longer needed

Options support groups, items, canInteract, onSelect, event and serverEvent. For exact parameter types, use the official ox_target client API and TargetOptions reference.

Troubleshooting

  • No such export addBoxZone: check the resource folder name and startup order.
  • Target never appears: temporarily set debug = true, verify coordinates and confirm ox_target is running.
  • Police-only option never shows: verify the player's ESX job and grade, then test without groups to isolate the filter.
  • Server event fires but no item appears: inspect server-side permission, distance and inventory checks.
  • Old qtarget script: the compatibility layer is limited; use native ox_target exports for new scripts.

Frequently asked questions

Independent documentation

esx-fivem.com is a community project and is not affiliated with the ESX Framework team. Facts on this page were checked against the upstream source. Official resources: docs.esx-framework.org and github.com/esx-framework.

Last updated on

On this page