Usage

Basic Dialog Structure

    local dialogData = {
        id = "example_dialog", -- Unique dialog identifier
        title = "NPC Name", -- NPC's name
        role = "NPC Role", -- NPC's role/occupation
        roleColor = "#ff000077", -- Role badge color
        roleBorderColor = "#ff0000", -- Role badge border color
        text = "Welcome message", -- Initial greeting text
        ped = ped, -- NPC entity object
        options = {
            {
                title = "Option 1", -- Dialog option title
                description = "Option 1 description", -- Brief description
                text = "NPC response text", -- Text shown when option is selected
                onSelect = function()
                    -- Code executed when option is selected
                end,
                next = { -- Sub-menu options
                    {
                        title = "Sub-option 1",
                        description = "Sub-option 1 description",
                        text = "Response for sub-option 1",
                        onSelect = function()
                            -- Code executed when sub-option is selected
                        end,
                        close = true -- Closes dialog when selected and typing text will be end
                    }
                }
            }
        }
    }

Properties

  • id: Unique identifier for the dialog

  • title: NPC's name displayed in dialog

  • role: NPC's role or occupation

  • roleColor (optional): Displayed badge color

  • roleBorderColor (optional): Displayed badge border color

  • text: Initial greeting message

  • ped: Reference to the NPC entity

  • options: Array of dialog options

Option Properties

  • title: Option text shown in menu

  • description (optional): Additional description text

  • text: NPC's response when selected

  • onSelect(close?, response?) (optional): Function triggered on selection

    • close() (optional) : Close dialog immediately

    • response(text) (optional) : Update dialog text

  • next (optional): Sub-menu options array

  • close (optional): Boolean to close dialog after selection

Example Usage

Exports

CreateDialog

This function creates a new dialog and returns the dialog id

ShowDialog

This function shows the dialog with the given id

RemoveDialog

This function removes the dialog with the given id, if you send second true, ped will be removed

Last updated