### Complete Option Configuration Example Source: https://context7.com/communityox/ox_target/llms.txt Demonstrates all available properties for target options, including identification, distance, requirements, conditional display, action handlers, and menu system integration. Use this for comprehensive target setup. ```lua exports.ox_target:addBoxZone({ name = 'example_zone', coords = vec3(0, 0, 0), size = vec3(2, 2, 2), options = { { -- Identification name = 'unique_option_name', -- unique identifier for removal label = 'Display Label', -- text shown to player icon = 'fa-solid fa-star', -- FontAwesome icon -- Distance & Positioning distance = 2.5, -- max interaction distance (default: 7) bones = { 'door_dside_f' }, -- entity bone targeting offset = vec3(0.5, 0.5, 0.5), -- position offset offsetSize = 1.0, -- offset interaction radius absoluteOffset = false, -- use absolute vs relative offset -- Requirements groups = { -- job/group requirements ['police'] = 2, -- minimum grade ['ambulance'] = 0, -- any grade }, items = { -- item requirements ['keycard'] = 1, -- minimum count }, anyItem = false, -- true = any item, false = all items -- Conditional Display canInteract = function(entity, distance, coords, name, bone) -- Return true to show option, false to hide return not IsPedInAnyVehicle(cache.ped, false) end, -- Action Handlers (use only one) onSelect = function(data) -- data.entity - targeted entity handle -- data.coords - interaction coordinates -- data.distance - distance to target -- data.zone - zone ID if targeting zone print('Selected!', json.encode(data)) end, event = 'myresource:clientEvent', -- trigger client event serverEvent = 'myresource:serverEvent', -- trigger server event command = 'mycommand', -- execute command export = 'myExportFunction', -- call resource export -- Menu System openMenu = 'submenu_name', -- open nested menu menuName = 'parent_menu', -- only show in this menu } } }) ``` -------------------------------- ### Add Box Zone Configuration Source: https://context7.com/communityox/ox_target/llms.txt Demonstrates how to add a box zone with all available target options. ```APIDOC ## POST /api/ox_target/addBoxZone ### Description Adds a box zone to the target system with specified options. ### Method POST ### Endpoint /api/ox_target/addBoxZone ### Parameters #### Request Body - **name** (string) - Required - Unique identifier for the zone. - **coords** (vector3) - Required - World coordinates of the zone center. - **size** (vector3) - Required - Dimensions of the box zone. - **options** (table) - Required - Table of target options for this zone. - **name** (string) - Required - Unique identifier for the option. - **label** (string) - Required - Text displayed to the player. - **icon** (string) - Optional - FontAwesome icon for the option. - **distance** (number) - Optional - Maximum interaction distance (default: 7). - **bones** (table) - Optional - Entity bone names for targeting. - **offset** (vector3) - Optional - Position offset for interaction. - **offsetSize** (number) - Optional - Interaction radius around the offset. - **absoluteOffset** (boolean) - Optional - Use absolute vs. relative offset. - **groups** (table) - Optional - Job/group requirements (e.g., `{{['police'] = 2}}`). - **items** (table) - Optional - Item requirements (e.g., `{{['keycard'] = 1}}`). - **anyItem** (boolean) - Optional - True if any item is sufficient, false otherwise. - **canInteract** (function) - Optional - Function to determine if the option can be interacted with. - **onSelect** (function) - Optional - Callback function when the option is selected. - **event** (string) - Optional - Client event to trigger on selection. - **serverEvent** (string) - Optional - Server event to trigger on selection. - **command** (string) - Optional - Command to execute on selection. - **export** (string) - Optional - Resource export function to call on selection. - **openMenu** (string) - Optional - Name of a submenu to open. - **menuName** (string) - Optional - Only show this option in the specified menu. ### Request Example ```lua exports.ox_target:addBoxZone({ name = 'example_zone', coords = vec3(0, 0, 0), size = vec3(2, 2, 2), options = { { name = 'unique_option_name', label = 'Display Label', icon = 'fa-solid fa-star', distance = 2.5, groups = { ['police'] = 2 }, items = { ['keycard'] = 1 }, canInteract = function(entity, distance, coords, name, bone) return not IsPedInAnyVehicle(cache.ped, false) end, onSelect = function(data) print('Selected!', json.encode(data)) end, event = 'myresource:clientEvent', serverEvent = 'myresource:serverEvent', command = 'mycommand', export = 'myExportFunction', openMenu = 'submenu_name', menuName = 'parent_menu' } } }) ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### qtarget Compatibility Layer Source: https://context7.com/communityox/ox_target/llms.txt Demonstrates how to use qtarget-style exports which are converted to ox_target format. ```APIDOC ## qtarget Compatibility Layer ### Description This section details how ox_target provides compatibility with qtarget/qb-target APIs by automatically converting options. ### AddBoxZone (qtarget style) #### Method POST #### Endpoint /api/qtarget/AddBoxZone #### Parameters - **name** (string) - Required - Name of the zone. - **coords** (vector3) - Required - Coordinates of the zone center. - **radius1** (number) - Required - First radius dimension. - **radius2** (number) - Required - Second radius dimension. - **zoneProperties** (table) - Optional - Properties for the zone (e.g., `heading`, `debugPoly`). - **options** (table) - Required - Table of target options. - **action** (function) - Converted to `onSelect`. - **icon** (string) - FontAwesome icon. - **label** (string) - Display label. - **job** (string) - Converted to `groups`. - **item** (string) - Converted to `items`. - **distance** (number) - Optional - Interaction distance. ### Request Example (AddBoxZone) ```lua exports.qtarget:AddBoxZone('shop_zone', vector3(25.0, -1347.0, 29.5), 1.5, 1.5, { name = 'shop_zone', heading = 0, debugPoly = false, minZ = 28.5, maxZ = 30.5, }, { options = { { action = function(entity) print('Interacted with shop') end, icon = 'fas fa-shopping-bag', label = 'Open Shop', job = 'shopkeeper', item = 'shop_key' } }, distance = 2.5, }) ``` ### AddTargetModel (qtarget style) #### Method POST #### Endpoint /api/qtarget/AddTargetModel #### Parameters - **model** (string) - Required - The model hash or name to target. - **options** (table) - Required - Table of target options. - **action** (function) - Converted to `onSelect`. - **icon** (string) - FontAwesome icon. - **label** (string) - Display label. - **distance** (number) - Optional - Interaction distance. ### Request Example (AddTargetModel) ```lua exports.qtarget:AddTargetModel('prop_vend_soda_01', { options = { { action = function(entity) TriggerEvent('vendingmachine:use') end, icon = 'fas fa-wine-bottle', label = 'Buy Drink' } }, distance = 1.5, }) ``` ### AddTargetEntity (qtarget style) #### Method POST #### Endpoint /api/qtarget/AddTargetEntity #### Parameters - **entity** (entity) - Required - The entity to target. - **options** (table) - Required - Table of target options. - **type** (string) - Optional - 'server' to trigger server event. - **event** (string) - Required if type is 'server' - Server event to trigger. - **icon** (string) - FontAwesome icon. - **label** (string) - Display label. - **distance** (number) - Optional - Interaction distance. ### Request Example (AddTargetEntity) ```lua exports.qtarget:AddTargetEntity(entity, { options = { { type = 'server', event = 'myresource:serverCallback', icon = 'fas fa-user', label = 'Interact' } }, distance = 2.0, }) ``` ``` -------------------------------- ### qtarget Compatibility: Model Targeting Source: https://context7.com/communityox/ox_target/llms.txt Uses the qtarget export to target a specific model, showing compatibility with qtarget's model targeting. The 'action' callback is converted to 'onSelect'. ```lua -- qtarget-style model targeting exports.qtarget:AddTargetModel('prop_vend_soda_01', { options = { { action = function(entity) TriggerEvent('vendingmachine:use') end, icon = 'fas fa-wine-bottle', label = 'Buy Drink', } }, distance = 1.5, }) ``` -------------------------------- ### Handle Server-Side Entity Events Source: https://context7.com/communityox/ox_target/llms.txt Use these events to listen for entity option registration or route interaction requests to the appropriate entity owner. ```lua -- Server-side: Listen for entity option registration RegisterNetEvent('ox_target:setEntityHasOptions', function(netId) -- Entity now has target options registered -- State is synced across all clients end) -- Server-side: Handle vehicle door toggle request RegisterNetEvent('ox_target:toggleEntityDoor', function(netId, door) local entity = NetworkGetEntityFromNetworkId(netId) if not DoesEntityExist(entity) then return end local owner = NetworkGetEntityOwner(entity) TriggerClientEvent('ox_target:toggleEntityDoor', owner, netId, door) end) ``` -------------------------------- ### qtarget Compatibility: Box Zone Source: https://context7.com/communityox/ox_target/llms.txt Uses the qtarget export to add a box zone, demonstrating compatibility with qtarget's API. Options like 'action', 'job', and 'item' are automatically converted to ox_target's format. ```lua -- qtarget-style box zone (compatibility) exports.qtarget:AddBoxZone('shop_zone', vector3(25.0, -1347.0, 29.5), 1.5, 1.5, { name = 'shop_zone', heading = 0, debugPoly = false, minZ = 28.5, maxZ = 30.5, }, { options = { { action = function(entity) -- 'action' converted to 'onSelect' print('Interacted with shop') end, icon = 'fas fa-shopping-bag', label = 'Open Shop', job = 'shopkeeper', -- 'job' converted to 'groups' item = 'shop_key', -- 'item' converted to 'items' } }, distance = 2.5, }) ``` -------------------------------- ### addSphereZone - Create a Spherical Interaction Zone Source: https://context7.com/communityox/ox_target/llms.txt Creates a spherical zone defined by center coordinates and radius. Useful for circular areas like fountains, statues, or points of interest. ```APIDOC ## POST /ox_target/addSphereZone ### Description Creates a spherical zone for player interactions, defined by its center coordinates and radius. This is ideal for circular areas such as fountains or points of interest. The function returns a unique zone ID. ### Method EXPORTS ### Endpoint exports.ox_target:addSphereZone ### Parameters #### Request Body - **name** (string) - Required - A unique identifier for the zone. - **coords** (vector3) - Required - The center coordinates (x, y, z) of the sphere zone. - **radius** (number) - Required - The radius of the spherical zone. - **debug** (boolean) - Optional - If true, visualizes the zone for debugging. Defaults to false. - **options** (table) - Required - A table of interaction options available within the zone. Each option can include: - **name** (string) - Required - The name of the interaction option. - **icon** (string) - Optional - The icon to display for the option. - **label** (string) - Required - The text label for the option. - **distance** (number) - Optional - The maximum distance from which the option can be interacted with. - **canInteract** (function) - Optional - A callback function to determine if the player can interact. - **serverEvent** (string) - Optional - The server event to trigger when the option is selected. ### Request Example ```lua local pumpZone = exports.ox_target:addSphereZone({ name = 'gas_pump_station_01', coords = vec3(-724.6, -935.1, 19.2), radius = 2.5, debug = true, options = { { name = 'refuel_vehicle', icon = 'fa-solid fa-gas-pump', label = 'Refuel Vehicle', distance = 3.0, canInteract = function(entity, distance, coords, name) local vehicle = GetVehiclePedIsIn(cache.ped, true) return vehicle ~= 0 end, serverEvent = 'fuel:refuelVehicle' } } }) ``` ### Response #### Success Response (200) - **zoneId** (number) - The unique ID of the created zone. #### Response Example ```json { "zoneId": 456 } ``` ``` -------------------------------- ### Add Box Zone with Options Source: https://context7.com/communityox/ox_target/llms.txt Creates a rectangular interaction zone. Define its dimensions, rotation, and attach options with conditions like distance, job groups, items, and interaction callbacks. Returns a zone ID for later removal. ```lua local zoneId = exports.ox_target:addBoxZone({ name = 'bank_atm_01', coords = vec3(149.5, -1040.5, 29.3), size = vec3(1.5, 1.0, 2.0), -- width, length, height rotation = 45, debug = false, -- set true to visualize zone drawSprite = true, -- show sprite indicator options = { { name = 'withdraw_cash', icon = 'fa-solid fa-money-bill-wave', label = 'Withdraw Cash', distance = 2.0, groups = { ['police'] = 0, ['ambulance'] = 0 }, -- job requirements items = 'bank_card', -- required item canInteract = function(entity, distance, coords, name) return not IsPlayerDead() end, onSelect = function(data) print('Opening ATM at zone:', data.zone) TriggerEvent('banking:openATM', data.coords) end }, { name = 'check_balance', icon = 'fa-solid fa-credit-card', label = 'Check Balance', event = 'banking:checkBalance', -- trigger client event } } }) -- Remove the zone when no longer needed exports.ox_target:removeZone(zoneId) ``` -------------------------------- ### qtarget Compatibility: Entity Targeting Source: https://context7.com/communityox/ox_target/llms.txt Uses the qtarget export to target a specific entity, demonstrating compatibility with qtarget's entity targeting. The 'type' option is used to trigger a server event. ```lua -- qtarget-style entity targeting exports.qtarget:AddTargetEntity(entity, { options = { { type = 'server', -- triggers server event instead of client event = 'myresource:serverCallback', icon = 'fas fa-user', label = 'Interact', } }, distance = 2.0, }) ``` -------------------------------- ### Add Global Options Source: https://context7.com/communityox/ox_target/llms.txt Registers target options that are always available, regardless of the targeted entity. Supports nested menus. ```lua -- Add a global emote menu option exports.ox_target:addGlobalOption({ name = 'open_emote_menu', icon = 'fa-solid fa-face-smile', label = 'Emote Menu', distance = 0, -- always available onSelect = function(data) TriggerEvent('emotes:openMenu') end }) -- Add nested menu system exports.ox_target:addGlobalOption({ { name = 'main_interactions', icon = 'fa-solid fa-bars', label = 'Interactions', openMenu = 'interactions_menu', -- opens submenu }, { name = 'int_wave', icon = 'fa-solid fa-hand', label = 'Wave', menuName = 'interactions_menu', -- only shows in this menu onSelect = function() ExecuteCommand('e wave') end }, { name = 'int_sit', icon = 'fa-solid fa-chair', label = 'Sit Down', menuName = 'interactions_menu', onSelect = function() ExecuteCommand('e sit') end } }) exports.ox_target:removeGlobalOption('open_emote_menu') ``` -------------------------------- ### State Management APIs Source: https://context7.com/communityox/ox_target/llms.txt Functions to control the targeting system state and check its activity status. ```APIDOC ## LUA State Management ### disableTargeting(state) - **state** (boolean) - Required - True to disable, false to enable. ### isActive() - Returns (boolean) - True if the player is currently using the targeting system. ### Usage Example ```lua -- Disable targeting exports.ox_target:disableTargeting(true) -- Check state if exports.ox_target:isActive() then print('Targeting is active') end ``` ``` -------------------------------- ### addBoxZone - Create a Box-Shaped Interaction Zone Source: https://context7.com/communityox/ox_target/llms.txt Creates a rectangular box zone where players can interact with target options. The zone is defined by center coordinates, size dimensions, and optional rotation. Returns a numeric zone ID that can be used to remove the zone later. ```APIDOC ## POST /ox_target/addBoxZone ### Description Creates a rectangular box zone for player interactions. This zone is defined by its center coordinates, dimensions (width, length, height), and an optional rotation. A unique zone ID is returned upon successful creation, which can be used for subsequent zone management. ### Method EXPORTS ### Endpoint exports.ox_target:addBoxZone ### Parameters #### Request Body - **name** (string) - Required - A unique identifier for the zone. - **coords** (vector3) - Required - The center coordinates (x, y, z) of the box zone. - **size** (vector3) - Required - The dimensions of the box zone (width, length, height). - **rotation** (number) - Optional - The rotation angle of the zone in degrees. - **debug** (boolean) - Optional - If true, visualizes the zone for debugging. Defaults to false. - **drawSprite** (boolean) - Optional - If true, displays a sprite indicator for the zone. Defaults to false. - **options** (table) - Required - A table of interaction options available within the zone. Each option can include: - **name** (string) - Required - The name of the interaction option. - **icon** (string) - Optional - The icon to display for the option (e.g., Font Awesome class). - **label** (string) - Required - The text label for the option. - **distance** (number) - Optional - The maximum distance from which the option can be interacted with. - **groups** (table) - Optional - A table specifying job groups and their required grades for interaction. - **items** (string or table) - Optional - The item(s) required to interact with this option. - **canInteract** (function) - Optional - A callback function to determine if the player can interact. - **onSelect** (function) - Optional - A callback function executed when the option is selected. - **event** (string) - Optional - The client event to trigger when the option is selected. - **serverEvent** (string) - Optional - The server event to trigger when the option is selected. ### Request Example ```lua local zoneId = exports.ox_target:addBoxZone({ name = 'bank_atm_01', coords = vec3(149.5, -1040.5, 29.3), size = vec3(1.5, 1.0, 2.0), -- width, length, height rotation = 45, debug = false, drawSprite = true, options = { { name = 'withdraw_cash', icon = 'fa-solid fa-money-bill-wave', label = 'Withdraw Cash', distance = 2.0, groups = { [\'police\'] = 0, [\'ambulance\'] = 0 }, items = 'bank_card', canInteract = function(entity, distance, coords, name) return not IsPlayerDead() end, onSelect = function(data) print('Opening ATM at zone:', data.zone) TriggerEvent('banking:openATM', data.coords) end }, { name = 'check_balance', icon = 'fa-solid fa-credit-card', label = 'Check Balance', event = 'banking:checkBalance' } } }) ``` ### Response #### Success Response (200) - **zoneId** (number) - The unique ID of the created zone. #### Response Example ```json { "zoneId": 123 } ``` ``` -------------------------------- ### Add Options to All Players Source: https://context7.com/communityox/ox_target/llms.txt Use `addGlobalPlayer` to register target options for other player characters. The `event` property can be used for simple actions, or `onSelect` for custom logic. Options can be removed later. ```lua -- Add player interaction options exports.ox_target:addGlobalPlayer({ { name = 'trade_player', icon = 'fa-solid fa-handshake', label = 'Trade', distance = 3.0, onSelect = function(data) local serverId = GetPlayerServerId(NetworkGetPlayerIndexFromPed(data.entity)) TriggerServerEvent('trade:request', serverId) end }, { name = 'give_item', icon = 'fa-solid fa-gift', label = 'Give Item', distance = 2.0, event = 'inventory:giveItem' } }) ``` -------------------------------- ### Add Options to Local Entities Source: https://context7.com/communityox/ox_target/llms.txt Registers target options for client-side entities that are not networked. Options can be added and removed. ```lua -- Create local prop and add target options local object = CreateObject(`prop_vend_snak_01`, 300.0, 300.0, 30.0, false, false, false) exports.ox_target:addLocalEntity(object, { name = 'use_vending', icon = 'fa-solid fa-cookie', label = 'Buy Snack', distance = 2.0, onSelect = function(data) TaskTurnPedToFaceEntity(cache.ped, data.entity, 500) Wait(500) TaskStartScenarioInPlace(cache.ped, 'PROP_HUMAN_ATM', 0, true) Wait(3000) ClearPedTasks(cache.ped) TriggerServerEvent('vending:buyItem', 'snack') end }) -- Remove local entity options exports.ox_target:removeLocalEntity(object, 'use_vending') ``` -------------------------------- ### addPolyZone - Create a Polygon-Shaped Interaction Zone Source: https://context7.com/communityox/ox_target/llms.txt Creates a polygon zone defined by an array of points. Ideal for irregularly shaped areas like building interiors, parking lots, or custom boundaries. ```APIDOC ## POST /ox_target/addPolyZone ### Description Creates a polygon-shaped zone for player interactions, defined by an array of 3D points. This is suitable for irregularly shaped areas such as building interiors or custom boundaries. The function returns a unique zone ID. ### Method EXPORTS ### Endpoint exports.ox_target:addPolyZone ### Parameters #### Request Body - **name** (string) - Required - A unique identifier for the zone. - **points** (table) - Required - An array of vector3 points defining the polygon vertices. - **thickness** (number) - Optional - The vertical thickness of the polygon zone. Defaults to 4.0. - **debug** (boolean) - Optional - If true, visualizes the zone for debugging. Defaults to false. - **options** (table) - Required - A table of interaction options available within the zone. Each option can include: - **name** (string) - Required - The name of the interaction option. - **icon** (string) - Optional - The icon to display for the option. - **label** (string) - Required - The text label for the option. - **groups** (table) - Optional - A table specifying job groups and their required grades for interaction. - **onSelect** (function) - Optional - A callback function executed when the option is selected. - **event** (string) - Optional - The client event to trigger when the option is selected. - **serverEvent** (string) - Optional - The server event to trigger when the option is selected. ### Request Example ```lua local warehouseZone = exports.ox_target:addPolyZone({ name = 'warehouse_storage', points = { vec3(1000.0, 1000.0, 30.0), vec3(1020.0, 1000.0, 30.0), vec3(1020.0, 1030.0, 30.0), vec3(1000.0, 1030.0, 30.0), }, thickness = 4.0, debug = false, options = { { name = 'access_storage', icon = 'fa-solid fa-boxes-stacked', label = 'Access Storage', groups = { ['trucker'] = 2 }, onSelect = function(data) TriggerServerEvent('warehouse:openStorage', data.zone) end } } }) ``` ### Response #### Success Response (200) - **zoneId** (number) - The unique ID of the created zone. #### Response Example ```json { "zoneId": 789 } ``` ``` -------------------------------- ### addGlobalPlayer Source: https://context7.com/communityox/ox_target/llms.txt Registers target options that appear on other player characters. ```APIDOC ## addGlobalPlayer ### Description Registers target options that appear on other player characters. ### Parameters #### Request Body - **options** (table) - Required - A table of option tables for player interactions. ``` -------------------------------- ### addGlobalObject Source: https://context7.com/communityox/ox_target/llms.txt Registers target options that appear on all world objects. ```APIDOC ## addGlobalObject ### Description Registers target options that appear on all world objects (props). ### Parameters #### Request Body - **options** (table) - Required - A table containing the target option configuration. ``` -------------------------------- ### Add Polygon Zone with Group Requirement Source: https://context7.com/communityox/ox_target/llms.txt Creates a polygon-shaped interaction zone for irregular areas. Options can enforce group requirements, such as a minimum job grade, and trigger server events. ```lua -- Create a polygon zone for a warehouse interior local warehouseZone = exports.ox_target:addPolyZone({ name = 'warehouse_storage', points = { vec3(1000.0, 1000.0, 30.0), vec3(1020.0, 1000.0, 30.0), vec3(1020.0, 1030.0, 30.0), vec3(1000.0, 1030.0, 30.0), }, thickness = 4.0, -- vertical thickness debug = false, options = { { name = 'access_storage', icon = 'fa-solid fa-boxes-stacked', label = 'Access Storage', groups = { ['trucker'] = 2 }, -- minimum grade 2 required onSelect = function(data) TriggerServerEvent('warehouse:openStorage', data.zone) end } } }) ``` -------------------------------- ### Check if a Zone Exists Source: https://context7.com/communityox/ox_target/llms.txt Use `zoneExists` to determine if a zone with a given ID or name is currently active. This is useful for conditional logic based on player location. ```lua -- Check by ID if exports.ox_target:zoneExists(123) then print('Zone 123 exists') end -- Check by name if exports.ox_target:zoneExists('bank_atm_01') then print('Bank ATM zone is active') end ``` -------------------------------- ### Add Options to Specific Models Source: https://context7.com/communityox/ox_target/llms.txt Use `addModel` to register target options for entities with specific model hashes. You can provide a single model hash or a list of hashes. Options can be removed later using `removeModel`. ```lua -- Add options to ATM models exports.ox_target:addModel({'prop_atm_01', 'prop_atm_02', 'prop_atm_03', 'prop_fleeca_atm'}, { { name = 'use_atm', icon = 'fa-solid fa-building-columns', label = 'Use ATM', distance = 1.5, onSelect = function(data) TriggerEvent('banking:openATM') end } }) -- Add options to specific vehicle model exports.ox_target:addModel('police', { name = 'access_police_laptop', icon = 'fa-solid fa-laptop', label = 'Access MDT', groups = 'police', distance = 2.0, onSelect = function(data) TriggerEvent('mdt:open') end }) -- Remove model options exports.ox_target:removeModel({'prop_atm_01', 'prop_atm_02'}, 'use_atm') ``` -------------------------------- ### Add Options to All Vehicles Source: https://context7.com/communityox/ox_target/llms.txt Use `addGlobalVehicle` to register target options that will appear on all vehicles. You can specify bones for bone-specific targeting and use `canInteract` to control when an option is available. Options can be removed later using `removeGlobalVehicle`. ```lua -- Add lockpick option to all vehicles exports.ox_target:addGlobalVehicle({ { name = 'lockpick_vehicle', icon = 'fa-solid fa-key', label = 'Lockpick Door', bones = { 'door_dside_f', 'door_pside_f' }, -- only show near these bones distance = 1.5, items = 'lockpick', canInteract = function(entity, distance, coords, name, bone) return GetVehicleDoorLockStatus(entity) == 2 -- locked end, onSelect = function(data) TriggerEvent('lockpick:startMinigame', data.entity) end }, { name = 'check_trunk', icon = 'fa-solid fa-car-rear', label = 'Check Trunk', offset = vec3(0.5, 0, 0.5), -- relative to vehicle dimensions offsetSize = 1.0, distance = 2.0, onSelect = function(data) local plate = GetVehicleNumberPlateText(data.entity) TriggerServerEvent('trunk:open', plate) end } }) -- Remove specific options later exports.ox_target:removeGlobalVehicle({ 'lockpick_vehicle', 'check_trunk' }) ``` -------------------------------- ### Add Options to All Peds Source: https://context7.com/communityox/ox_target/llms.txt Use `addGlobalPed` to register target options for all NPC peds. Ensure `canInteract` is set to false for player characters if they should not be targeted by these options. Options can be removed later. ```lua -- Add robbery option to all peds exports.ox_target:addGlobalPed({ name = 'rob_ped', icon = 'fa-solid fa-hand-holding-dollar', label = 'Rob Pedestrian', distance = 2.0, items = { ['weapon_pistol'] = 1 }, -- requires having a pistol canInteract = function(entity, distance, coords, name) return not IsPedDeadOrDying(entity, true) and not IsPedAPlayer(entity) end, onSelect = function(data) TaskTurnPedToFaceEntity(data.entity, cache.ped, 1000) TriggerServerEvent('robbery:startPedRob', PedToNet(data.entity)) end }) ``` -------------------------------- ### Add Sphere Zone with Interaction Source: https://context7.com/communityox/ox_target/llms.txt Creates a spherical interaction zone. Useful for circular areas. Options can include conditions like checking if the player is in a vehicle and trigger server events. ```lua -- Create a sphere zone around a gas pump local pumpZone = exports.ox_target:addSphereZone({ name = 'gas_pump_station_01', coords = vec3(-724.6, -935.1, 19.2), radius = 2.5, debug = true, options = { { name = 'refuel_vehicle', icon = 'fa-solid fa-gas-pump', label = 'Refuel Vehicle', distance = 3.0, canInteract = function(entity, distance, coords, name) local vehicle = GetVehiclePedIsIn(cache.ped, true) return vehicle ~= 0 end, serverEvent = 'fuel:refuelVehicle', -- trigger server event } } }) ``` -------------------------------- ### addGlobalPed Source: https://context7.com/communityox/ox_target/llms.txt Registers target options that appear on all NPC peds. ```APIDOC ## addGlobalPed ### Description Registers target options that appear on all NPC peds (excluding players). ### Parameters #### Request Body - **options** (table) - Required - A table containing the target option configuration. ``` -------------------------------- ### zoneExists Source: https://context7.com/communityox/ox_target/llms.txt Checks if a zone exists by its ID or name. ```APIDOC ## zoneExists ### Description Returns true if a zone with the specified ID or name exists. ### Parameters #### Arguments - **idOrName** (number|string) - Required - The ID or name of the zone to check. ### Response - **exists** (boolean) - Returns true if the zone exists, otherwise false. ``` -------------------------------- ### addModel Source: https://context7.com/communityox/ox_target/llms.txt Registers target options that only appear on entities with specific model hashes. ```APIDOC ## addModel ### Description Registers target options that only appear on entities with specific model hashes. ### Parameters #### Arguments - **models** (string|table) - Required - A single model name or a table of model names. - **options** (table) - Required - A table of option tables to apply to these models. ``` -------------------------------- ### Add Options to Networked Entities Source: https://context7.com/communityox/ox_target/llms.txt Registers target options for specific networked entities using their network ID. Options can be added, removed individually, or all removed. ```lua -- Add options to a specific spawned NPC local ped = CreatePed(4, `a_m_m_business_01`, 200.0, 200.0, 30.0, 0.0, true, true) local netId = NetworkGetNetworkIdFromEntity(ped) exports.ox_target:addEntity(netId, { { name = 'talk_shopkeeper', icon = 'fa-solid fa-comment', label = 'Talk to Shopkeeper', distance = 2.5, onSelect = function(data) TriggerEvent('dialogue:startConversation', 'shopkeeper') end }, { name = 'buy_items', icon = 'fa-solid fa-shopping-cart', label = 'Browse Shop', distance = 2.5, serverEvent = 'shop:openMenu' } }) -- Remove specific option exports.ox_target:removeEntity(netId, 'talk_shopkeeper') -- Remove all options from entity exports.ox_target:removeEntity(netId) ``` -------------------------------- ### Add Options to All Objects Source: https://context7.com/communityox/ox_target/llms.txt Use `addGlobalObject` to register target options for all world objects (props). The `canInteract` function can filter objects based on their model hash or other properties. Options can be removed later. ```lua -- Add option to all garbage objects exports.ox_target:addGlobalObject({ name = 'search_garbage', icon = 'fa-solid fa-dumpster', label = 'Search Garbage', distance = 2.0, canInteract = function(entity, distance, coords, name) local model = GetEntityModel(entity) local garbageModels = { [`prop_dumpster_01a`] = true, [`prop_dumpster_02a`] = true, [`prop_bin_01a`] = true, } return garbageModels[model] end, onSelect = function(data) TriggerEvent('scavenging:searchContainer', data.entity) end }) ``` -------------------------------- ### addGlobalVehicle Source: https://context7.com/communityox/ox_target/llms.txt Registers target options that appear on all vehicles in the world. ```APIDOC ## addGlobalVehicle ### Description Registers target options that appear on all vehicles in the world. Supports bone-specific targeting and offset-based positioning. ### Parameters #### Request Body - **options** (table) - Required - A table of option tables containing name, icon, label, distance, and optional fields like bones, offset, items, canInteract, and onSelect. ``` -------------------------------- ### addEntity / removeEntity Source: https://context7.com/communityox/ox_target/llms.txt Registers or removes target options for specific networked entities using their network ID. ```APIDOC ## LUA exports.ox_target:addEntity ### Description Registers target options for specific networked entities using their network ID. ### Parameters - **netId** (number) - Required - The network ID of the entity. - **options** (table) - Required - A table of option objects containing name, icon, label, distance, and callback logic. ### Usage Example ```lua local netId = NetworkGetNetworkIdFromEntity(ped) exports.ox_target:addEntity(netId, { { name = 'talk_shopkeeper', icon = 'fa-solid fa-comment', label = 'Talk to Shopkeeper', distance = 2.5, onSelect = function(data) TriggerEvent('dialogue:startConversation', 'shopkeeper') end } }) -- Remove specific option exports.ox_target:removeEntity(netId, 'talk_shopkeeper') -- Remove all options exports.ox_target:removeEntity(netId) ``` ``` -------------------------------- ### addGlobalOption / removeGlobalOption Source: https://context7.com/communityox/ox_target/llms.txt Registers or removes target options that are available globally regardless of the targeted entity. ```APIDOC ## LUA exports.ox_target:addGlobalOption ### Description Registers target options that are always available. Supports nested menus via menuName and openMenu properties. ### Parameters - **options** (table) - Required - A table or array of option objects. ### Usage Example ```lua exports.ox_target:addGlobalOption({ name = 'open_emote_menu', icon = 'fa-solid fa-face-smile', label = 'Emote Menu', onSelect = function(data) TriggerEvent('emotes:openMenu') end }) exports.ox_target:removeGlobalOption('open_emote_menu') ``` ``` -------------------------------- ### Check if Targeting is Active Source: https://context7.com/communityox/ox_target/llms.txt Returns whether the targeting system is currently active, meaning the player is holding or has toggled the target key. Can be used to modify game elements like timecycle modifiers. ```lua -- Check targeting state in a loop CreateThread(function() while true do if exports.ox_target:isActive() then -- Player is currently targeting SetTimecycleModifier('hud_def_blur') else ClearTimecycleModifier() end Wait(100) end end) ``` -------------------------------- ### Disable/Enable Targeting System Source: https://context7.com/communityox/ox_target/llms.txt Temporarily disables or re-enables the targeting system. Useful for preventing interaction during events like cutscenes. ```lua -- Disable targeting during cutscene exports.ox_target:disableTargeting(true) -- Play cutscene... Wait(5000) -- Re-enable targeting exports.ox_target:disableTargeting(false) ``` -------------------------------- ### Remove Zone by ID or Name Source: https://context7.com/communityox/ox_target/llms.txt Removes a previously created zone using its numeric ID or string name. An optional boolean argument can suppress warnings if the zone does not exist. ```lua -- Remove zone by numeric ID exports.ox_target:removeZone(zoneId) ``` ```lua -- Remove zone by name exports.ox_target:removeZone('bank_atm_01') ``` ```lua -- Remove zone without warning if it doesn't exist exports.ox_target:removeZone('maybe_exists', true) ``` -------------------------------- ### removeZone - Remove an Existing Zone Source: https://context7.com/communityox/ox_target/llms.txt Removes a previously created zone by its ID or name. Can optionally suppress warnings if the zone doesn't exist. ```APIDOC ## DELETE /ox_target/removeZone ### Description Removes a previously created interaction zone using its unique ID or name. This function can optionally suppress warning messages if the specified zone does not exist. ### Method EXPORTS ### Endpoint exports.ox_target:removeZone ### Parameters #### Path Parameters - **zoneIdentifier** (number or string) - Required - The ID or name of the zone to remove. - **suppressWarnings** (boolean) - Optional - If true, suppresses warnings if the zone is not found. Defaults to false. ### Request Example ```lua -- Remove zone by numeric ID exports.ox_target:removeZone(zoneId) -- Remove zone by name exports.ox_target:removeZone('bank_atm_01') -- Remove zone without warning if it doesn't exist exports.ox_target:removeZone('maybe_exists', true) ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the zone was successfully removed or if it did not exist (and suppressWarnings was true). #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### addLocalEntity / removeLocalEntity Source: https://context7.com/communityox/ox_target/llms.txt Registers or removes target options for client-side entities that are not networked. ```APIDOC ## LUA exports.ox_target:addLocalEntity ### Description Registers target options for client-side entities that aren't networked. ### Parameters - **entity** (number) - Required - The entity handle. - **options** (table) - Required - A table of option objects. ### Usage Example ```lua exports.ox_target:addLocalEntity(object, { name = 'use_vending', icon = 'fa-solid fa-cookie', label = 'Buy Snack', distance = 2.0, onSelect = function(data) TriggerServerEvent('vending:buyItem', 'snack') end }) -- Remove local entity options exports.ox_target:removeLocalEntity(object, 'use_vending') ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.