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 dialogtitle: NPC's name displayed in dialogrole: NPC's role or occupationroleColor (optional): Displayed badge colorroleBorderColor (optional): Displayed badge border colortext: Initial greeting messageped: Reference to the NPC entityoptions: Array of dialog options
Option Properties
title: Option text shown in menudescription (optional): Additional description texttext: NPC's response when selectedonSelect(close?, response?) (optional): Function triggered on selectionclose() (optional): Close dialog immediatelyresponse(text) (optional): Update dialog text
next (optional): Sub-menu options arrayclose (optional): Boolean to close dialog after selection
Example Usage
local dialogId = exports["5s_dialogs"]:CreateDialog(dialogData)
exports["5s_dialogs"]:ShowDialog(dialogId)Exports
CreateDialog
exports["5s_dialogs"]:CreateDialog(dialogData)This function creates a new dialog and returns the dialog id
ShowDialog
exports["5s_dialogs"]:ShowDialog(dialogId)This function shows the dialog with the given id
RemoveDialog
exports["5s_dialogs"]:RemoveDialog(dialogId, removePed)This function removes the dialog with the given id, if you send second true, ped will be removed
Last updated