> For the complete documentation index, see [llms.txt](https://tgiann.gitbook.io/tgiann/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tgiann.gitbook.io/tgiann/scripts/tgiann-radialmenu-target/target.md). Agents can also search and read this documentation through its [MCP server](https://tgiann.gitbook.io/tgiann/~gitbook/mcp).

# Target

The built-in target (third eye) system. It answers the **ox\_target**, **tgiann-target** and **qb-target** exports, so other scripts work with it without any change. Settings are in `configs/configTarget.lua`.

### How it works

* Targets around the player show a small ring. Rings show up `markerDistance` meters before the player is in reach; out of reach rings are dimmed.
* Aim at a ring with the crosshair and it turns into a key prompt. Hold the interact key (**E** by default) for `holdDuration` ms to use it.
* A target with one option runs it right away, a target with more options opens the radial menu in the player's own style.
* Targets closer than `clusterDistance` to each other share one marker and open together.
* Options added with `addGlobalOption` (not tied to a target) are on the radial menu's main page (F3), not on the target key.
* Targeting is off while the player is dead, a menu or NUI has focus, the pause menu is open, or a script camera / the cinematic camera is active.
* Built-in vehicle options (doors, hood, trunk) can be turned off with `defaultOptions = false`.

### Player settings

Players change these in the menu: Settings > Target. Server defaults are in `config.radialDefaultSettings`.

* **Interact key**: the key held to use a target.
* **Show markers on a key**: rings of targets out of reach only show while the markers key is held. Targets in reach always show and aiming works without the key.
* **Markers key**: the key that shows every ring (Alt by default).

### Options

Options use the ox\_target fields.

| Field                   | Type                                             | Description                                                                               |
| ----------------------- | ------------------------------------------------ | ----------------------------------------------------------------------------------------- |
| `label`                 | `string`                                         | Text shown for the option                                                                 |
| `name`                  | `string`                                         | Id used to remove or replace the option                                                   |
| `icon`                  | `string`                                         | Font Awesome icon (`"fa-solid fa-car"` or `"car"`)                                        |
| `distance`              | `number`                                         | Interaction distance in meters, default `config.target.defaultDistance`                   |
| `groups`                | `string \| string[] \| table<string, number>`    | Jobs / gangs, with a minimum grade in the table form                                      |
| `items`                 | `string \| string[] \| table<string, number>`    | Required items, with an amount in the table form                                          |
| `anyItem`               | `boolean`                                        | One of `items` is enough                                                                  |
| `bones`                 | `string \| string[]`                             | Entity bones the marker sits on                                                           |
| `offset`                | `vector3`                                        | Marker position relative to the entity size (0-1), or meters with `absoluteOffset = true` |
| `canInteract`           | `function(entity, distance, coords, name, bone)` | Hide the option by returning false                                                        |
| `onSelect`              | `function(data)`                                 | Runs on the client                                                                        |
| `export`                | `string`                                         | `"resource.ExportName"`, called with `data`                                               |
| `event`                 | `string`                                         | Client event, gets `data`                                                                 |
| `serverEvent`           | `string`                                         | Server event, gets `data` (`entity` is a net id)                                          |
| `command`               | `string`                                         | Chat command to run                                                                       |
| `openMenu` / `menuName` | `string`                                         | Sub menus: an option with `openMenu = "x"` opens the options with `menuName = "x"`        |

`data` holds the option fields plus `entity`, `coords`, `distance` and `zone` (zone id).

### ox\_target / tgiann-target exports

```lua
exports.ox_target:addLocalEntity(ped, {
    {
        name = "talk",
        label = "Talk",
        icon = "fa-solid fa-comments",
        distance = 2.0,
        onSelect = function(data)
            print(data.entity)
        end,
    },
})
```

| Export                                                                      | Description                                                             |
| --------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| `addBoxZone(data)`                                                          | Box zone (`coords`, `size`, `rotation`, `options`), returns the zone id |
| `addSphereZone(data)`                                                       | Sphere zone (`coords`, `radius`, `options`), returns the zone id        |
| `addPolyZone(data)`                                                         | Poly zone (`points`, `thickness`, `options`), returns the zone id       |
| `removeZone(id, suppressWarning?)`                                          | Removes a zone by id or name                                            |
| `zoneExists(id)`                                                            | Whether a zone with this id or name exists                              |
| `addGlobalPed(options)` / `removeGlobalPed(names)`                          | Options on every ped                                                    |
| `addGlobalVehicle(options)` / `removeGlobalVehicle(names)`                  | Options on every vehicle                                                |
| `addGlobalObject(options)` / `removeGlobalObject(names)`                    | Options on every object                                                 |
| `addGlobalPlayer(options)` / `removeGlobalPlayer(names)`                    | Options on every player                                                 |
| `addGlobalOption(options)` / `removeGlobalOption(names)`                    | Options not tied to a target, shown on the radial menu's main page      |
| `addModel(models, options)` / `removeModel(models, names?)`                 | Options on every entity of these models                                 |
| `addEntity(netIds, options)` / `removeEntity(netIds, names?)`               | Options on networked entities                                           |
| `addLocalEntity(entities, options)` / `removeLocalEntity(entities, names?)` | Options on local entity handles                                         |
| `getTargetOptions(entity?, type?, model?)`                                  | Raw option lists of an entity (or the global options without an entity) |
| `getNearbyEntities(coords, maxDistance)`                                    | Entities registered by handle or net id near a point                    |
| `disableTargeting(state)`                                                   | `true` turns targeting off                                              |
| `isActive()`                                                                | Whether targeting is on                                                 |

Global ped / vehicle / object options only show markers within `globalRadius` and on the closest `globalLimit` entities.

### qb-target exports

With `qbTargetCompat = true`, `exports["qb-target"]` calls are turned into the options above. Job, gang and item requirements are kept.

`AddCircleZone`, `AddBoxZone`, `AddPolyZone`, `AddEntityZone`, `RemoveZone`, `AddTargetEntity`, `RemoveTargetEntity`, `AddTargetModel`, `RemoveTargetModel`, `AddTargetBone`, `RemoveTargetBone`, `AddGlobalPed`, `RemoveGlobalPed`, `AddGlobalVehicle`, `RemoveGlobalVehicle`, `AddGlobalObject`, `RemoveGlobalObject`, `AddGlobalPlayer`, `RemoveGlobalPlayer`, `RemoveGlobalTypeOptions`, `AllowTargeting`, `RaycastCamera`, `SpawnPed`, `RemoveSpawnedPed`

`AddComboZone` is not supported, the call is ignored with a warning.
