---
description: >-
  ES-Dialogue is a comprehensive NPC dialogue system for FiveM servers. It
  allows server owners to create interactive NPCs with custom dialogue options
  that can trigger various server and client events.
---

# NPC DIALOG

### 1. Introduction

```
## Features
- Easy to configure NPC spawning
- Interactive dialogue system with multiple response options
- Support for multiple frameworks (QBCore, ESX)
- Dynamic mugshot generation from NPC models
- Customizable NPC appearances and animations
- Event-based interactions for shop systems, quests, and more
```

2\. Installation

### Prerequisites

* FiveM Server (Not mandatory, but there is a choice of sample config)
* QBCore or ESX Framework (Not mandatory, but there is a choice of sample config)
* Standalone (The code is actually standalone, you can only select default ESX - QBCore in controls such as item export)

### 3. Configuration

<figure><img src="https://3675563864-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHYPEuf5iNSxLbr9k1kWd%2Fuploads%2Fc9sNEYFIIs5QIf5WkGlA%2Fimage.png?alt=media&#x26;token=20a960e5-73ae-48f9-8056-ee5d9b021cf4" alt=""><figcaption></figcaption></figure>

```
## 4. NPC System
```

```lua
Locations = {
    { 
        coords = vector3(29.49, -1345.12, 29.5), -- NPC position
        id = "market_npc",                       -- Unique identifier
        name = "Shop Owner",                     -- Display name
        avatar = "",                             -- Custom avatar (optional)
        message = "Welcome to my store!",        -- Default greeting
        color = "#55aaff",                       -- Theme color
        model = "a_m_y_business_03",             -- Ped model
        heading = 250.0,                         -- Facing direction
        scenario = "WORLD_HUMAN_CLIPBOARD",      -- Animation
        -- Additional options...
    },
    -- More NPCs...
}
```

NPCs are defined in the Config.Locations table. Each NPC can have unique properties:

## Configuration

### Framework Configuration

ES-Dialogue supports multiple frameworks. Configure your framework in the shared.lua file:

```lua
Config = {
    Framework = 'QBCore',  -- Options: 'QBCore', 'ESX', 'OLDQBCore', or 'NewESX'
    -- Additional configuration...
}
```

### NPC Configuration

NPCs are defined in the Config.Locations table. Each NPC can have unique properties:

```lua
Locations = {
    { 
        coords = vector3(29.49, -1345.12, 29.5), -- NPC position
        id = "market_npc",                       -- Unique identifier
        name = "Shop Owner",                     -- Display name
        avatar = "",                             -- Custom avatar (optional)
        message = "Welcome to my store!",        -- Default greeting
        color = "#55aaff",                       -- Theme color
        model = "a_m_y_business_03",             -- Ped model
        heading = 250.0,                         -- Facing direction
        scenario = "WORLD_HUMAN_CLIPBOARD",      -- Animation
        -- Additional options...
    },
    -- More NPCs...
}
```

### 4. NPC System

1. The NPC will face the player
2. Text will appear above the NPC
3. An interaction prompt will be displayed
4. Pressing E opens

Players can interact with NPCs by approaching them and pressing E. When in range:

### NPC Interactions

* Custom appearance (model)
* Unique position and heading
* Idle animations (scenarios)
* Interactive text display
* Custom dialogue options

ES-Dialogue automatically spawns NPCs defined in your configuration. Each NPC can have:

### Creating NPCs

## NPC System

### 5. Dialogue System

### Configuring Dialogues

Each NPC can have multiple dialogue options configured throughn text value = "buy\_fooifier type =d", -- Unique option identifier type = -- Event type:server "server" or "client" trigger = "servervent to -- Arguments trigger args = { -- Arguments type = action = "ich", buy", item = "sandwich", count = 1 } }, -- More options... }ue options can trigger:

* Server events (for purchases, quest progress, etc.)
* Client events (for animations, UI changes, etc.)
* Additional dialogues (for multi-step conversations)

Events receive the configured args object, allowing for dynamic responses.

7\. Examples

```
exports['es-dialogue']:ShowNPCDialog({
    id = "npc_id",              -- NPC identifier
    name = "NPC Name",          -- Display name
    avatar = "path/to/avatar",  -- Optional
    message = "Hello player!",  -- Greeting message
    color = "#55aaff",          -- Theme color
    options = {                 -- Response options
        -- Options configuration
    }
})
```

#### client.lua (exit)

```
exports['es-dialogue']:CloseNPCDialog()
```

server.lua (example trigger)

```
RegisterServerEvent('server:eyestore')
AddEventHandler('server:eyestore', function(args)
    local src = source
    local Player = Framework.Functions.GetPlayer(src)
    -- Handle different item types
    if args.type == "food" then
        Config.Add(Player, args.item, args.count)
    -- Additional item types...
    end
end)
```

shared.lua

```
{ 
    coords = vector3(29.49, -1345.12, 29.5),
    id = "market_npc",
    name = "Shop Owner",
    message = "Welcome to my store! How can I help you today?",
    color = "#55aaff",
    model = "a_m_y_business_03",
    heading = 250.0,
    scenario = "WORLD_HUMAN_CLIPBOARD",
    drawText = {
        text = "~b~Shop Owner",
        yOffset = 1.0,
    },
    options = {
        {
            label = "Buy Sandwich",
            value = "buy_food",
            type = "server",
            trigger = "server:eyestore",
            args = { type = "food", item = "sandwich", count = 1 },
        },
        {
            label = "Ask About Prices",
            value = "ask_prices",
            type = "client",
            trigger = "fck:client",
            args = {}
        },
    }
}
```
