Skip to content

TheHorizonDev/mojito_dialogue

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mojito Dialogue 💬

Simple to use NPC interaction / dialogue system to take a user's input. NPC spawning is optimised and handled by PolyZones.

Code Examples

There are two ways to access data from an NPC interaction as follows:

With Callback:

exports['mojito_dialogue']:NewDialogueCallback(`a_m_y_skater_02`, vec4(-727.74, -143.54, 36.36, 0.00), 20.0, {
    title = "Would you like to start a mission",
    items = {
        {text = "Yes", value="yes"},
        {text = "No", value="no"}
    }
}, function(selection)
    if selection == "yes" then
     QBCore.Functions.Notify("You picked yes", "success")
    else
     QBCore.Functions.Notify("You picked no", "error")
    end
end)

The result is returned as a callback function with argument 0 being the selection value in string form.

With Event:

exports['mojito_dialogue']:NewDialogueEvent(`a_m_y_skater_02`, vec4(-727.74, -143.54, 36.36, 0.00), 20.0, {
    title = "Would you like to start a mission",
    items = {
        {text = "Yes", value="yes"},
        {text = "No", value="no"}
    }
}, "myscript:client:onInteract")

AddEventHandler("myscript:client:onInteract", function(selection)
    print(selection) -- "yes" or "no" 
end)

The result is returned as the first argument to the specified client event

Video Preview

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Lua 68.8%
  • JavaScript 16.0%
  • CSS 10.5%
  • HTML 4.7%