CU Enhanced Target
Client Functions

Client Functions

All functions are client-side exports. Replace cu_enchanced_target with your actual resource name if you renamed it to ox_target, qb-target, or qtarget.

For detailed examples, refer to defaults.lua (opens in a new tab) or debug.lua (opens in a new tab) in the ox_target repository.

Zone Functions

addSphereZone

Creates a spherical targeting zone and returns its ID.

Parameters:

exports.cu_enchanced_target:addSphereZone(parameters)
  • parameters - table
    • coords - vector3 (required)
    • radius - number (default: 2.0)
    • name - string (optional, recommended for removal)
    • debug - boolean (default: false)
    • drawSprite - boolean (default: true)
    • options - table (required, see Target Options)

Returns: number (zone ID)

Example:

local zoneId = exports.cu_enchanced_target:addSphereZone({
  coords = vec3(123.45, 567.89, 21.0),
  radius = 1.5,
  name = 'stash_zone',
  debug = false,
  drawSprite = true,
  options = {
    {
      name = 'open_stash',
      label = 'Open Stash',
      icon = 'fa-solid fa-box',
      onSelect = function(data)
        print('Opening stash')
      end
    }
  }
})

addBoxZone

Creates a box-shaped targeting zone and returns its ID.

Parameters:

exports.cu_enchanced_target:addBoxZone(parameters)
  • parameters - table
    • coords - vector3 (required)
    • size - vector3 (default: vec3(2.0, 2.0, 2.0))
    • rotation - number (default: 0.0, in degrees)
    • name - string (optional)
    • debug - boolean (default: false)
    • drawSprite - boolean (default: true)
    • options - table (required)

Returns: number (zone ID)

Example:

local zoneId = exports.cu_enchanced_target:addBoxZone({
  coords = vec3(100.0, 200.0, 30.0),
  size = vec3(2.0, 2.0, 2.0),
  rotation = 45.0,
  name = 'shop_counter',
  options = {
    {
      label = 'Access Shop',
      icon = 'fa-solid fa-shopping-cart',
      event = 'shop:open'
    }
  }
})

addPolyZone

Creates a polygon targeting zone and returns its ID.

Parameters:

exports.cu_enchanced_target:addPolyZone(parameters)
  • parameters - table
    • points - vector3[] (required, array of 3D points)
    • thickness - number (default: 4, height of the polygon)
    • name - string (optional)
    • debug - boolean (default: false)
    • drawSprite - boolean (default: true)
    • options - table (required)

Returns: number (zone ID)

Example:

local zoneId = exports.cu_enchanced_target:addPolyZone({
  points = {
    vec3(100.0, 200.0, 30.0),
    vec3(110.0, 200.0, 30.0),
    vec3(110.0, 210.0, 30.0),
    vec3(100.0, 210.0, 30.0)
  },
  thickness = 2.0,
  name = 'parking_zone',
  options = {
    {
      label = 'Park Vehicle',
      icon = 'fa-solid fa-square-parking',
      onSelect = function(data)
        print('Parking vehicle')
      end
    }
  }
})

zoneExists

Checks if a zone with the given ID or name exists.

Parameters:

exports.cu_enchanced_target:zoneExists(id)
  • id - number or string (zone ID or name)

Returns: boolean

Example:

if exports.cu_enchanced_target:zoneExists('stash_zone') then
  print('Zone exists')
end
 
if exports.cu_enchanced_target:zoneExists(12) then
  print('Zone with ID 12 exists')
end

removeZone

Removes a targeting zone by ID or name.

Parameters:

exports.cu_enchanced_target:removeZone(id)
  • id - number or string (zone ID or name)

Example:

exports.cu_enchanced_target:removeZone('stash_zone')
exports.cu_enchanced_target:removeZone(zoneId)

Global Entity Type Functions

addGlobalOption

Adds target options that appear for all entity types (peds, vehicles, objects).

Parameters:

exports.cu_enchanced_target:addGlobalOption(options)
  • options - TargetOptions (table or array of tables)

Example:

exports.cu_enchanced_target:addGlobalOption({
  {
    name = 'examine',
    label = 'Examine',
    icon = 'fa-solid fa-magnifying-glass',
    onSelect = function(data)
      print('Examining entity', data.entity)
    end
  }
})

removeGlobalOption

Removes global options by name.

Parameters:

exports.cu_enchanced_target:removeGlobalOption(optionNames)
  • optionNames - string or string[] (option name or array of names)

Example:

exports.cu_enchanced_target:removeGlobalOption('examine')
exports.cu_enchanced_target:removeGlobalOption({'examine', 'inspect'})

addGlobalPed

Adds target options to all Ped entities (excluding players).

Parameters:

exports.cu_enchanced_target:addGlobalPed(options)
  • options - TargetOptions

Example:

exports.cu_enchanced_target:addGlobalPed({
  {
    name = 'greet_ped',
    label = 'Greet',
    icon = 'fa-solid fa-hand-wave',
    distance = 3.0,
    onSelect = function(data)
      print('Greeting ped')
    end
  }
})

removeGlobalPed

Removes options from all peds.

Parameters:

exports.cu_enchanced_target:removeGlobalPed(optionNames)
  • optionNames - string or string[]

addGlobalPlayer

Adds target options to all Player entities.

Parameters:

exports.cu_enchanced_target:addGlobalPlayer(options)
  • options - TargetOptions

Example:

exports.cu_enchanced_target:addGlobalPlayer({
  {
    name = 'give_money',
    label = 'Give Money',
    icon = 'fa-solid fa-dollar-sign',
    onSelect = function(data)
      -- Your logic here
    end
  }
})

removeGlobalPlayer

Removes options from all players.

Parameters:

exports.cu_enchanced_target:removeGlobalPlayer(optionNames)
  • optionNames - string or string[]

addGlobalVehicle

Adds target options to all Vehicle entities.

Parameters:

exports.cu_enchanced_target:addGlobalVehicle(options)
  • options - TargetOptions

Example:

exports.cu_enchanced_target:addGlobalVehicle({
  {
    name = 'check_plate',
    label = 'Check Plate',
    icon = 'fa-solid fa-id-card',
    bones = {'platelight'},
    onSelect = function(data)
      local plate = GetVehicleNumberPlateText(data.entity)
      print('Plate:', plate)
    end
  }
})

removeGlobalVehicle

Removes options from all vehicles.

Parameters:

exports.cu_enchanced_target:removeGlobalVehicle(optionNames)
  • optionNames - string or string[]

addGlobalObject

Adds target options to all Object entities.

Parameters:

exports.cu_enchanced_target:addGlobalObject(options)
  • options - TargetOptions

Example:

exports.cu_enchanced_target:addGlobalObject({
  {
    name = 'pickup_object',
    label = 'Pick Up',
    icon = 'fa-solid fa-hand',
    onSelect = function(data)
      print('Picking up object')
    end
  }
})

removeGlobalObject

Removes options from all objects.

Parameters:

exports.cu_enchanced_target:removeGlobalObject(optionNames)
  • optionNames - string or string[]

Model Functions

addModel

Adds target options for specific model(s).

Parameters:

exports.cu_enchanced_target:addModel(models, options)
  • models - number, string, or array of numbers/strings (model hash or name)
  • options - TargetOptions

Example:

-- Single model
exports.cu_enchanced_target:addModel('prop_atm_01', {
  {
    label = 'Use ATM',
    icon = 'fa-solid fa-money-bill',
    event = 'bank:openATM'
  }
})
 
-- Multiple models
exports.cu_enchanced_target:addModel({`prop_atm_01`, `prop_atm_02`, `prop_atm_03`}, {
  {
    label = 'Use ATM',
    icon = 'fa-solid fa-money-bill',
    event = 'bank:openATM'
  }
})
 
-- String model names
exports.cu_enchanced_target:addModel({'prop_vend_snak_01', 'prop_vend_water_01'}, {
  {
    label = 'Buy Snack',
    icon = 'fa-solid fa-cookie',
    event = 'vending:buy'
  }
})

removeModel

Removes options from specific model(s).

Parameters:

exports.cu_enchanced_target:removeModel(models, optionNames)
  • models - number, string, or array of numbers/strings
  • optionNames - string or string[]

Example:

exports.cu_enchanced_target:removeModel('prop_atm_01', 'use_atm')
exports.cu_enchanced_target:removeModel({`prop_atm_01`, `prop_atm_02`}, {'use_atm', 'check_balance'})

Entity Functions

addEntity

Adds target options for specific networked entity/entities.

Uses network IDs (see NetworkGetNetworkIdFromEntity (opens in a new tab)).

Parameters:

exports.cu_enchanced_target:addEntity(netIds, options)
  • netIds - number or number[] (network ID or array of network IDs)
  • options - TargetOptions

Example:

local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
local netId = NetworkGetNetworkIdFromEntity(vehicle)
 
exports.cu_enchanced_target:addEntity(netId, {
  {
    name = 'check_trunk',
    label = 'Open Trunk',
    icon = 'fa-solid fa-box-open',
    bones = {'boot'},
    onSelect = function(data)
      SetVehicleDoorOpen(data.entity, 5, false, false)
    end
  }
})

removeEntity

Removes options from networked entity/entities.

Parameters:

exports.cu_enchanced_target:removeEntity(netIds, optionNames)
  • netIds - number or number[]
  • optionNames - string or string[]

Example:

exports.cu_enchanced_target:removeEntity(netId, 'check_trunk')

addLocalEntity

Adds target options for local entity/entities (client-side only).

Parameters:

exports.cu_enchanced_target:addLocalEntity(entities, options)
  • entities - number or number[] (entity handle)
  • options - TargetOptions

Example:

local ped = CreatePed(4, GetHashKey('a_m_m_business_01'), x, y, z, heading, false, false)
 
exports.cu_enchanced_target:addLocalEntity(ped, {
  {
    name = 'talk_npc',
    label = 'Talk',
    icon = 'fa-solid fa-comment',
    onSelect = function(data)
      print('Starting conversation')
    end
  }
})

removeLocalEntity

Removes options from local entity/entities.

Parameters:

exports.cu_enchanced_target:removeLocalEntity(entities, optionNames)
  • entities - number or number[]
  • optionNames - string or string[]

Example:

exports.cu_enchanced_target:removeLocalEntity(ped, 'talk_npc')

Utility Functions

getTargetOptions

Retrieves all target options currently available for an entity.

Parameters:

exports.cu_enchanced_target:getTargetOptions(entity, entityType, model)
  • entity - number (optional, entity handle)
  • entityType - number (optional, 1 for peds, 2 for vehicles, 3 for objects)
  • model - number (optional, model hash)

Returns: table with keys:

  • global - Global options for the entity type
  • model - Options for the specific model
  • entity - Options for the networked entity
  • localEntity - Options for the local entity

Example:

local entity = GetVehiclePedIsIn(PlayerPedId(), false)
local entityType = 2  -- Vehicle
local model = GetEntityModel(entity)
 
local options = exports.cu_enchanced_target:getTargetOptions(entity, entityType, model)
print('Model options:', json.encode(options.model))

disableTargeting

Enable or disable the targeting system.

Parameters:

exports.cu_enchanced_target:disableTargeting(state)
  • state - boolean
    • true - Turns off targeting and prevents it from reopening
    • false - Re-enables targeting

Example:

-- Disable targeting during cutscene
exports.cu_enchanced_target:disableTargeting(true)
-- Play cutscene...
Wait(5000)
-- Re-enable targeting
exports.cu_enchanced_target:disableTargeting(false)

isActive

Checks if the targeting system is currently active.

Returns: boolean

Example:

if exports.cu_enchanced_target:isActive() then
  print('Player is currently targeting')
end

Quick Reference

Zone Functions:

  • addSphereZone - Create sphere zone
  • addBoxZone - Create box zone
  • addPolyZone - Create polygon zone
  • removeZone - Remove zone
  • zoneExists - Check if zone exists

Global Options:

  • addGlobalOption - Add to all entities
  • addGlobalPed - Add to all peds
  • addGlobalPlayer - Add to all players
  • addGlobalVehicle - Add to all vehicles
  • addGlobalObject - Add to all objects
  • removeGlobalOption - Remove global options
  • removeGlobalPed - Remove ped options
  • removeGlobalPlayer - Remove player options
  • removeGlobalVehicle - Remove vehicle options
  • removeGlobalObject - Remove object options

Model & Entity Functions:

  • addModel - Add to specific models
  • addEntity - Add to network entities
  • addLocalEntity - Add to local entities
  • removeModel - Remove model options
  • removeEntity - Remove entity options
  • removeLocalEntity - Remove local entity options

Utility Functions:

  • getTargetOptions - Get options for entity
  • disableTargeting - Enable/disable targeting
  • isActive - Check if targeting active