# NPC Dialog System

`NPC Dialog System` is a FiveM conversation resource that allows players to interact with NPCs through multi-page dialogs, button choices, selection lists, and optional TTS voice lines.

It is designed for immersive roleplay interactions such as shops, quests, information points, jobs, faction NPCs, and story-driven conversations. Dialogs can trigger client or server events, switch between pages, close automatically, and stream generated voice audio in real time.

With an in-game admin panel, database storage, voice support, and flexible page logic, the system is powerful, scalable, and easy to manage.

### Features

* Multi-page NPC dialogs
* Button-based conversation flow
* Optional selection lists
* Real-time TTS voice support
* Supports ElevenLabs and OpenAI
* Automatic audio caching
* In-game admin panel for dialog creation
* Persistent database storage
* Client and server event triggers
* Custom NPC models, text, icons, animations, and voices
* Optional map blips

### How it works

Players approach an NPC and press `E` to start a conversation.

When the dialog opens, the camera focuses on the NPC and the UI displays the current page text along with available buttons. Each button can move to another page, trigger a client event, trigger a server event, or close the dialog.

If TTS is enabled, the NPC text is converted into audio on the server and streamed to the client. Generated voice lines can be cached to avoid duplicate API requests.

All dialogs are stored in the database and loaded automatically when the resource starts.

### Included Pages

* Installation
* Configuration

### Requirements

Before using this resource, make sure all required dependencies are installed and started correctly.

### Notes

* Dialogs are stored in the database
* NPCs can be created and managed in-game
* TTS voices support both ElevenLabs and OpenAI
* Client and server button events are fully customizable
* Make sure the UI is built before deploying the resource


---

# 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://mskscripts.gitbook.io/mskscripts/scripts/npc-dialog-system.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.
