# Public API

All exports are client-side. Each registration call returns an `id` you can reuse to remove or update the interaction.

#### `pedRegister(cfg)`

Spawn a streamed NPC at `coords` (must be a `vec4`, the `w` is the heading) and attach an interaction. Peds despawn automatically when the player walks out of `Config.Ped.spawnRange`.

```lua
exports["core_interact"]:pedRegister({
    coords   = vec4(-33.41, -1099.95, 25.41, 70.86),
    model    = "mp_m_weapexp_01",
    animDict = "amb@world_human_stand_mobile@male@text@base",
    animName = "base",
    hintIcon = "talk",
    blips    = { sprite = 119, color = 50, text = "Foreman" },
    dialogue = { name = "Paul", tag = "Lumberjack", startMsg = "Hi!", elements = { ... } },
})
```

#### `positionRegister(cfg)`

Static interaction at world coordinates (no NPC, no streaming). The `coords` field must be a `vec3` — pass a `vec4` and the call is ignored (use `pedRegister` for those).

#### `entityRegister(cfg)`

Bind an interaction to an existing entity handle. Optional `bone` field attaches the hint to a specific bone for moving entities.

```lua
exports["core_interact"]:entityRegister({
    entity   = vehicleHandle,
    bone     = "boot",
    hintIcon = "interact",
    message  = "Open trunk",
    onInteract = function(id, ent, spec) end,
})
```

#### `entityRegisterByHash(hash, cfg)`

Bind an interaction to **every** spawned instance of a model hash. A single shared scanner thread polls `GetGamePool("CObject")` every `Config.HashScanInterval` ms — adding 1 or 100 watchers has the same cost.

#### `interactCreate(cfg) → id` / `interactRemove(id)`

Dynamically add and remove an interaction at runtime — useful for quest-driven points that should appear, then disappear.

#### Lower-level

* `HandleHoldTextUI(id, data)`, `RemoveHoldTextUI(id)`, `CloseHoldTextUI(id)`, `RemoveHoldTextUIs()` — direct access to the hold panel system.
* `HandleTextUI(id, data)`, `CloseTextUI(id)`, `RemoveTextUI(id)`, `RemoveTextUIs()` — the simpler TextUI variant (no hold/hint).
* `Draw3DSprite({ duiHandler, coords, maxDistance, hintOnly })` — render a DUI as a 3D world-space sprite (called internally on every tick).
* `IsDuiVisible() → boolean` — true while at least one panel is on screen.
* `unlockLastInteract()` — re-arm the most recently locked interaction (after an async action finishes, for example).


---

# 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://doc.var-fivem.com/interaction/configuration/public-api.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.
