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
- Type:
string - Description: Font Awesome icon name (see Font Awesome Icons (opens in a new tab))
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.5bones
- Type:
string | string[] - Description: Specific bone(s) to target on entities (see GetEntityBoneIndexByName (opens in a new tab))
bones = 'door_dside_f'
bones = {'boot', 'bonnet'}Common vehicle bones:
door_dside_f- Driver doordoor_pside_f- Passenger doorboot- Trunkbonnet- Hoodwheel_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.0Interaction 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)
endParameters:
entity- The entity being targeted (or 0 for zones)distance- Distance to the targetcoords- World coordinates of the target pointname- Name of the optionbone- 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_lockpickMenu 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: onSelect → export → event → serverEvent → command
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)
endData table:
entity- Entity ID (or network ID for server events)coords- Target coordinates (vector3)distance- Distance to targetzone- 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
- Always set a name for options you might need to remove later
- Use appropriate distances to avoid cluttering the menu
- Optimize canInteract - avoid expensive operations
- Use framework integration (groups, items) when available
- Provide clear labels that describe the action
- Choose appropriate icons from Font Awesome
- Use submenus for related options to reduce clutter