CU Enhanced Target
Target Options

Target Options

Target options define the actions shown when a player targets an entity or zone. All target functions accept an array of option objects with the following properties.

TargetOption Properties

Basic Properties

label

  • Type: string
  • Required: Yes
  • Description: The text displayed in the targeting menu
label = 'Open Door'

name

  • Type: string
  • Description: Unique identifier for the option, used when removing or updating options
name = 'door_open'

icon

icon = 'fa-solid fa-door-open'

iconColor

  • Type: string
  • Description: CSS color for the icon
iconColor = '#ff0000'
iconColor = 'rgb(255, 0, 0)'
iconColor = 'red'

Distance & Positioning

distance

  • Type: number
  • Default: Varies by entity type
  • Description: Maximum distance (in game units) to display this option
distance = 2.5

bones

bones = 'door_dside_f'
bones = {'boot', 'bonnet'}

Common vehicle bones:

  • door_dside_f - Driver door
  • door_pside_f - Passenger door
  • boot - Trunk
  • bonnet - Hood
  • wheel_lf - Left front wheel

offset

  • Type: vector3
  • Description: Offset the targetable area relative to the model dimensions
offset = vec3(0.0, 0.0, 0.5)

offsetAbsolute

  • Type: vector3
  • Description: Offset the targetable area relative to the entity's world coordinates
offsetAbsolute = vec3(0.0, 1.0, 0.0)

offsetSize

  • Type: number
  • Description: Radius of the targetable area when using offsets
offsetSize = 1.0

Interaction Control

canInteract

  • Type: function(entity, distance, coords, name, bone)
  • Returns: boolean
  • Description: Function called to determine if the option should be shown
canInteract = function(entity, distance, coords, name, bone)
  return not IsPedInAnyVehicle(PlayerPedId(), false)
end

Parameters:

  • entity - The entity being targeted (or 0 for zones)
  • distance - Distance to the target
  • coords - World coordinates of the target point
  • name - Name of the option
  • bone - Bone ID if targeting a specific bone

Framework Integration

groups

  • Type: string | string[] | table<string, number>
  • Description: Required job/gang for the option to appear (framework dependent)
-- Simple group check
groups = 'police'
 
-- Multiple groups
groups = {'police', 'sheriff'}
 
-- Group with minimum grade
groups = {police = 2, sheriff = 1}

items

  • Type: string | string[] | table<string, number>
  • Description: Required item(s) for the option to appear (framework dependent)
-- Single item
items = 'lockpick'
 
-- Multiple items
items = {'lockpick', 'screwdriver'}
 
-- Item with quantity
items = {lockpick = 1, money = 100}

anyItem

  • Type: boolean
  • Default: false
  • Description: When true, only one item from the items table is required (OR logic instead of AND)
items = {'lockpick', 'advanced_lockpick'},
anyItem = true  -- requires lockpick OR advanced_lockpick

Menu System

menuName

  • Type: string
  • Description: Creates a submenu - option is only visible when this menu is active
menuName = 'vehicle_doors'

openMenu

  • Type: string
  • Description: Opens the specified submenu when this option is selected
openMenu = 'vehicle_doors'

Example submenu system:

{
  label = 'Vehicle Options',
  icon = 'fa-solid fa-car',
  openMenu = 'vehicle_menu'
},
{
  label = 'Open Driver Door',
  icon = 'fa-solid fa-door-open',
  menuName = 'vehicle_menu',
  onSelect = function(data)
    SetVehicleDoorOpen(data.entity, 0, false, false)
  end
}

Action Callbacks

Actions are executed in priority order: onSelectexporteventserverEventcommand

onSelect

  • Type: function(data)
  • Description: Function called when the option is selected
onSelect = function(data)
  print('Selected entity:', data.entity)
  print('At coords:', data.coords)
  print('Distance:', data.distance)
end

Data table:

  • entity - Entity ID (or network ID for server events)
  • coords - Target coordinates (vector3)
  • distance - Distance to target
  • zone - Zone ID/name (if applicable)

export

  • Type: string
  • Format: "resourceName.exportName"
  • Description: Calls the specified export
export = 'ox_inventory.openInventory'

event

  • Type: string
  • Description: Triggers a client-side event
event = 'my_resource:openDoor'

Receive event:

RegisterNetEvent('my_resource:openDoor', function(data)
  print('Entity:', data.entity)
end)

serverEvent

  • Type: string
  • Description: Triggers a server-side event
serverEvent = 'my_resource:serverOpenDoor'

Receive on server:

RegisterNetEvent('my_resource:serverOpenDoor', function(data)
  local source = source
  print('Player', source, 'targeted entity', data.entity)
end)

Note: For server events, the entity is sent as a network ID

command

  • Type: string
  • Description: Executes a client command
command = 'openinventory'

Complete Example

exports.cu_enchanced_target:addModel('prop_atm_01', {
  {
    name = 'atm_withdraw',
    label = 'Withdraw Money',
    icon = 'fa-solid fa-money-bill-wave',
    iconColor = '#00ff00',
    distance = 2.0,
    groups = {['civilian'] = 0},
    canInteract = function(entity, distance, coords)
      -- Only show between 8 AM and 8 PM
      local hour = GetClockHours()
      return hour >= 8 and hour < 20
    end,
    onSelect = function(data)
      TriggerEvent('bank:openATM', data.entity)
    end
  },
  {
    name = 'atm_deposit',
    label = 'Deposit Money',
    icon = 'fa-solid fa-piggy-bank',
    iconColor = '#0088ff',
    distance = 2.0,
    items = 'bank_card',
    serverEvent = 'bank:deposit'
  },
  {
    name = 'atm_check_balance',
    label = 'Check Balance',
    icon = 'fa-solid fa-receipt',
    distance = 2.0,
    event = 'bank:checkBalance'
  }
})

Best Practices

  1. Always set a name for options you might need to remove later
  2. Use appropriate distances to avoid cluttering the menu
  3. Optimize canInteract - avoid expensive operations
  4. Use framework integration (groups, items) when available
  5. Provide clear labels that describe the action
  6. Choose appropriate icons from Font Awesome
  7. Use submenus for related options to reduce clutter