# Target

The `Config.Target` section in the configuration file determines whether your server will use an external target system for NPC interactions (like `ox_target`), or fall back to the default method of displaying text over NPCs. Here's a breakdown of how this works:

**1. Target Enabled (`Config.Target.enabled = true`)**

When the `enabled` property is set to `true`, the server will rely on the external target system (in this case, `ox_target`). This means that NPC interactions will be handled by `ox_target`, and the user will need to use the target system's functionality to interact with NPCs.

* **Target Resource**: The `resource` field indicates which resource to use for the target system. In this example, it's set to `"ox_target"`, meaning it will use the `ox_target` resource to handle NPC interaction.

{% code title="shared/config.lua" %}

```lua
Config.Target = {
    enabled = false,
    resource = "ox_target",
}
```

{% endcode %}

* **Behavior**:
  * The NPC will have a dynamic interaction, and you will use the target system to interact with the NPC (e.g., a circle or indicator will appear around the NPC, and the player will click on the target to initiate interaction).
  * This method provides a more polished and integrated experience for NPC interactions.

**2. Target Disabled (`Config.Target.enabled = false`)**

When the `enabled` property is set to `false`, the server does **not** use any external target system, and the default interaction method is used. In this case, the NPC will show a **text label** above its head (such as "\[E] - Supermarket 24/7"), and players can press the configured key (e.g., \[E]) to interact with the NPC.

* **DrawText**: With `enabled = false`, the NPC interaction is based on a simple **text prompt** that appears above the NPC, usually controlled via `DrawText` or similar functions. This text will display the interaction key (e.g., `[E] - Supermarket 24/7`), instructing the player to press the corresponding button to interact.

  Example:

{% code title="shared/config.lua" %}

```lua
npc = {
    name = "Mark",
    hash = 0x18CE57D0,  -- Hash of the NPC model
    scenario = "WORLD_HUMAN_CLIPBOARD",  -- Scenario/animation for the NPC
    target = {
        icon = "fas fa-shopping-basket",  -- The icon to show with the target interaction (for ox_target)
        label = "[E] - Supermarket 24/7",  -- The label that will be shown over the NPC
        distance = 2.0,  -- Distance within which the interaction is possible
        key = 38,  -- The key used for interaction (38 corresponds to the [E] key)
    }
}
```

{% endcode %}

**Behavior**:

* When the `target` system is disabled, players will see a **text label** above the NPC, such as `[E] - Supermarket 24/7`. They can then press the key (e.g., `E` with key code `38`) to interact with the NPC.
* This method is simpler and does not require an external resource but still provides basic interaction functionality.

**Summary of Behavior Based on `Config.Target.enabled`**

| **Enabled** | **Method**                             | **Resource**         | **Interaction**                                               | **Key Binding**            |
| ----------- | -------------------------------------- | -------------------- | ------------------------------------------------------------- | -------------------------- |
| `true`      | Uses target system (e.g., `ox_target`) | `ox_target`          | Dynamic NPC interaction (circle, icons)                       | Configured via `ox_target` |
| `false`     | Draws text above the NPC's head        | No external resource | Simple interaction with text (e.g., `[E] - Supermarket 24/7`) | Customizable via `key`     |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kojascripts.eu/new/shops/configuration/target.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
