# Table of Contents - [Ox Target - Documentation](#ox-target-documentation) - [TargetOptions - Ox Target](#targetoptions-ox-target) - [Client - Ox Target](#client-ox-target) --- # Ox Target - Documentation Ox Target Ox Target ========= [Github](https://github.com/communityox/ox_target) [Releases](https://github.com/communityox/ox_target/releases) A performant and flexible standalone targeting resource or "third-eye", with additional functionality for ox\_inventory, ox\_core, qbx\_core, and es\_extended. Installation[](https://coxdocs.dev/ox_target#installation) ----------------------------------------------------------- We **strongly** recommend referring to [Guides](https://coxdocs.dev/guides) for setting up Git, Node.js, and pnpm. ### Install all resource dependencies[](https://coxdocs.dev/ox_target#install-all-resource-dependencies) * [ox\_lib](https://coxdocs.dev/ox_lib) ### Download a [release (opens in a new tab)](https://github.com/communityox/ox_target/releases) or clone the source code.[](https://coxdocs.dev/ox_target#download-a-release-or-clone-the-source-code) git clone https://github.com/communityox/ox_target.git ### Config[](https://coxdocs.dev/ox_target#config) Resource configuration is handled using [convars (opens in a new tab)](https://docs.fivem.net/docs/scripting-reference/convars/) . # Toggle targeting when pressing the hotkey, instead of holding it down. setr ox_target:toggleHotkey 0 # Change the key to enable targeting (https://docs.fivem.net/docs/game-references/input-mapper-parameter-ids/keyboard) setr ox_target:defaultHotkey LMENU # Draw a sprite (circle) at the centroid of a zone. setr ox_target:drawSprite 1 # Enable built-in targeting options, e.g. toggling vehicle doors. setr ox_target:defaults 1 # Enable debugging / testing options, entity outlines, and a raycast indicator. setr ox_target:debug 0 # Enable / Disable leftclick to select options setr ox_target:leftClick 1 Supported Frameworks[](https://coxdocs.dev/ox_target#supported-frameworks) --------------------------------------------------------------------------- These aren't necessary to run ox\_target, but they will add additional features. * [ox\_core (opens in a new tab)](https://github.com/communityox/ox_core) * [esx (opens in a new tab)](https://github.com/esx-framework/esx-legacy) * [qbx\_core (opens in a new tab)](https://github.com/Qbox-project/qbx_core) [Metadata](https://coxdocs.dev/ox_inventory/Guides/metadata "Metadata") [TargetOptions](https://coxdocs.dev/ox_target/TargetOptions "TargetOptions") --- # TargetOptions - Ox Target [Ox Target](https://coxdocs.dev/ox_target) TargetOptions TargetOptions ============= All target actions are formated as an array containing objects with the following properties. TargetOption[](https://coxdocs.dev/ox_target/TargetOptions#targetoption) ------------------------------------------------------------------------- * label: `string` * name?: `string` * An identifier used when removing an option. * icon?: `string` * Name of a [Font Awesome (opens in a new tab)](https://fontawesome.com/icons) icon. * iconColor?: `string` * distance?: `number` * The max distance to display the option. * bones?: `string` or `string[]` * A bone name or array of bone names (see [GetEntityBoneIndexByName (opens in a new tab)](https://docs.fivem.net/natives/?_0xFB71170B7E76ACBA) ). * offset?: `vector3` * Offset the targetable area of an entity, relative to the model dimensions. * offsetAbsolute?: `vector3` * Offset the targetable area of an entity, relative to the entity's world coords. * offsetSize?: `number` * The radius of the targetable area for an entity offset. * groups?: `string` or `string[]` or `table` * A group, array of groups, or pairs of groups-grades required to show the option. * Groups are framework dependent, and may refer to jobs, gangs, etc. * items?: `string` or `string[]` or `table` * An item, array of items, or pairs of items-count required to show the option. * Items are framework dependent. * anyItem?: `boolean` * Only require a single item from the items table to exist. * canInteract?: `function(entity, distance, coords, name, bone)` * Options will always display if this is undefined. * menuName?: `string` * The option is only displayed when a menu has been set with openMenu. * openMenu?: `string` * Sets the current menu name, displaying only options for the menuName. * onSelect?: `function(data)` * export?: `string` * event?: `string` * serverEvent?: `string` * command?: `string` Callback[](https://coxdocs.dev/ox_target/TargetOptions#callback) ----------------------------------------------------------------- This is the data returned to a registered callback or event for selected option. A selected option will trigger a single action, in order of priority: 1. onSelect 2. export 3. event 4. server event 5. command * data: `table` * entity: `number` * The id of the entity hit by the shape test. If triggering a server event, this is the network id instead. * coords: `vector3` * The resulting coordinates where the shape test hit a collision. * distance: `number` * The player's distance from the coords. * zone?: `number` * The id of the selected zone, if applicable. [Ox Target](https://coxdocs.dev/ox_target "Ox Target") [Client](https://coxdocs.dev/ox_target/Functions/Client "Client") --- # Client - Ox Target [Ox Target](https://coxdocs.dev/ox_target) Functions Client Client ====== All exports with the `options` argument expect a table with the targeting properties [here](https://coxdocs.dev/ox_target/TargetOptions) . For some examples you can refer to [defaults.lua (opens in a new tab)](https://github.com/communityox/ox_target/blob/main/client/defaults.lua) or [debug.lua (opens in a new tab)](https://github.com/communityox/ox_target/blob/main/client/debug.lua) . disableTargeting[](https://coxdocs.dev/ox_target/Functions/Client#disabletargeting) ------------------------------------------------------------------------------------ Toggle the availability of the targeting menu. exports.ox_target:disableTargeting(state) * state: `boolean` * Setting `state` to `true` will turn off the targeting eye if it is active and prevent it from reopening until `state` is set to `false` again. isActive[](https://coxdocs.dev/ox_target/Functions/Client#isactive) -------------------------------------------------------------------- Checks if the targeting system is currently active. exports.ox_target:isActive() Return: * `boolean` - Returns `true` if the targeting system is active, otherwise `false`. getTargetOptions[](https://coxdocs.dev/ox_target/Functions/Client#gettargetoptions) ------------------------------------------------------------------------------------ Retrieves targeting options for a specific entity. exports.ox_target:getTargetOptions(entity, entityType, model) * entity?: `number` - The entity handle * entityType?: `number` - The type of entity (1 for peds, 2 for vehicles, 3 for objects) * model?: `number` - The model hash of the entity Return: * `table` - Returns a table containing the target options for the entity: * global: Options for the entity type (peds, vehicles, or objects) * model: Options for the specific model * entity: Options for the networked entity * localEntity: Options for the local entity addGlobalOption[](https://coxdocs.dev/ox_target/Functions/Client#addglobaloption) ---------------------------------------------------------------------------------- Creates new targetable options which are displayed at all times. exports.ox_target:addGlobalOption(options) * options: `TargetOptions` removeGlobalOption[](https://coxdocs.dev/ox_target/Functions/Client#removeglobaloption) ---------------------------------------------------------------------------------------- Removes all options from the global options list with the option names. exports.ox_target:removeGlobalOption(optionNames) * optionNames: `string` or `string[]` addGlobalObject[](https://coxdocs.dev/ox_target/Functions/Client#addglobalobject) ---------------------------------------------------------------------------------- Creates new targetable options for all Object entity types. exports.ox_target:addGlobalObject(options) * options: `TargetOptions` removeGlobalObject[](https://coxdocs.dev/ox_target/Functions/Client#removeglobalobject) ---------------------------------------------------------------------------------------- Removes all options from the global Object list with the option names. exports.ox_target:removeGlobalObject(optionNames) * optionNames: `string` or `string[]` addGlobalPed[](https://coxdocs.dev/ox_target/Functions/Client#addglobalped) ---------------------------------------------------------------------------- Creates new targetable options for all Ped entity types (excluding players). exports.ox_target:addGlobalPed(options) * options: `TargetOptions` removeGlobalPed[](https://coxdocs.dev/ox_target/Functions/Client#removeglobalped) ---------------------------------------------------------------------------------- Removes all options from the global Ped list with the option names. exports.ox_target:removeGlobalPed(optionNames) * optionNames: `string` or `string[]` addGlobalPlayer[](https://coxdocs.dev/ox_target/Functions/Client#addglobalplayer) ---------------------------------------------------------------------------------- Creates new targetable options for all Player entities. exports.ox_target:addGlobalPlayer(options) * options: `TargetOptions` removeGlobalPlayer[](https://coxdocs.dev/ox_target/Functions/Client#removeglobalplayer) ---------------------------------------------------------------------------------------- Removes all options from the global Player list with the option names. exports.ox_target:removeGlobalPlayer(optionNames) * optionNames: `string` or `string[]` addGlobalVehicle[](https://coxdocs.dev/ox_target/Functions/Client#addglobalvehicle) ------------------------------------------------------------------------------------ Creates new targetable options for all Vehicle entity types. exports.ox_target:addGlobalVehicle(options) * options: `TargetOptions` removeGlobalVehicle[](https://coxdocs.dev/ox_target/Functions/Client#removeglobalvehicle) ------------------------------------------------------------------------------------------ Removes all options from the global Vehicle list with the option names. exports.ox_target:removeGlobalVehicle(optionNames) * optionNames: `string` or `string[]` addModel[](https://coxdocs.dev/ox_target/Functions/Client#addmodel) -------------------------------------------------------------------- Creates new targetable options for a specific model or list of models. exports.ox_target:addModel(models, options) * models: `number` or `string` or `Array` * options: `TargetOptions` removeModel[](https://coxdocs.dev/ox_target/Functions/Client#removemodel) -------------------------------------------------------------------------- Removes all options from the models list with the option names. exports.ox_target:removeModel(models, optionNames) * models: `number` or `string` or `Array` * optionNames: `string` or `string[]` addEntity[](https://coxdocs.dev/ox_target/Functions/Client#addentity) ---------------------------------------------------------------------- Creates new targetable options for a specific network id or list of network ids (see [NetworkGetNetworkIdFromEntity (opens in a new tab)](https://docs.fivem.net/natives/?_0x9E35DAB6) ). exports.ox_target:addEntity(netIds, options) * netIds: `number` or `number[]` * options: `TargetOptions` removeEntity[](https://coxdocs.dev/ox_target/Functions/Client#removeentity) ---------------------------------------------------------------------------- Removes all options from the networked entities list with the option names. exports.ox_target:removeEntity(netIds, optionNames) * netIds: `number` or `number[]` * optionNames: `string` or `string[]` addLocalEntity[](https://coxdocs.dev/ox_target/Functions/Client#addlocalentity) -------------------------------------------------------------------------------- Creates new targetable options for a specific entity handle or list of entity handles. exports.ox_target:addLocalEntity(entities, options) * entities: `number` or `number[]` * options: `TargetOptions` removeLocalEntity[](https://coxdocs.dev/ox_target/Functions/Client#removelocalentity) -------------------------------------------------------------------------------------- Removes all options from the entities list with the option names. exports.ox_target:removeLocalEntity(entities, optionNames) * entities: `number` or `number[]` * optionNames: `string` or `string[]` addSphereZone[](https://coxdocs.dev/ox_target/Functions/Client#addspherezone) ------------------------------------------------------------------------------ Creates a new targetable [sphere zone](https://coxdocs.dev/ox_lib/Modules/Zones/Shared#libzonessphere) . exports.ox_target:addSphereZone(parameters) * parameters: `table` * coords: `vector3` * name?: `string` * An optional name to refer to the zone instead of using the `id`. * radius?: `number` * debug?: `boolean` * drawSprite?: `boolean` * Draw a sprite at the centroid of the zone. Defaults to `true`. * options: `TargetOptions` Return: * id: `number` addBoxZone[](https://coxdocs.dev/ox_target/Functions/Client#addboxzone) ------------------------------------------------------------------------ Creates a new targetable [box zone](https://coxdocs.dev/ox_lib/Modules/Zones/Shared#libzonesbox) . exports.ox_target:addBoxZone(parameters) * parameters: `table` * coords: `vector3` * name?: `string` * An optional name to refer to the zone instead of using the `id`. * size?: `vector3` * rotation?: `number` * debug?: `boolean` * drawSprite?: `boolean` * Draw a sprite at the centroid of the zone. Defaults to `true`. * options: `TargetOptions` Return: * id: `number` addPolyZone[](https://coxdocs.dev/ox_target/Functions/Client#addpolyzone) -------------------------------------------------------------------------- Creates a new targetable [poly zone](https://coxdocs.dev/ox_lib/Modules/Zones/Shared#libzonespoly) . exports.ox_target:addPolyZone(parameters) * parameters: `table` * points: `vector3[]` * An array of 3d points defining the polygon's shape. * name?: `string` * An optional name to refer to the zone instead of using the `id`. * thickness?: `number` * The height of the polygon, defaulting to `4`. * debug?: `boolean` * drawSprite?: `boolean` * Draw a sprite at the centroid of the zone. Defaults to `true`. * options: `TargetOptions` Return: * id: `number` zoneExists[](https://coxdocs.dev/ox_target/Functions/Client#zoneexists) ------------------------------------------------------------------------ Checks if a zone with the given ID exists. exports.ox_target:zoneExists(id) * id: `number` or `string` * The `number` id that is returned by [addSphereZone](https://coxdocs.dev/ox_target/Functions/Client#addspherezone) , [addBoxZone](https://coxdocs.dev/ox_target/Functions/Client#addboxzone) , or [addPolyZone](https://coxdocs.dev/ox_target/Functions/Client#addpolyzone) **OR** * The `string` name given to the zone. Return: * `boolean` - Returns `true` if the zone exists, otherwise `false`. removeZone[](https://coxdocs.dev/ox_target/Functions/Client#removezone) ------------------------------------------------------------------------ Removes a targetable zone with the given id (returned by addBoxZone/addSphereZone). exports.ox_target:removeZone(id) * id: `number` or `string` * The `number` id that is returned by [addSphereZone](https://coxdocs.dev/ox_target/Functions/Client#addspherezone) , [addBoxZone](https://coxdocs.dev/ox_target/Functions/Client#addboxzone) , or [addPolyZone](https://coxdocs.dev/ox_target/Functions/Client#addpolyzone) **OR** * The `string` name given to the zone. [TargetOptions](https://coxdocs.dev/ox_target/TargetOptions "TargetOptions") ---