Code Monkey home page Code Monkey logo

qb-dialogue's Introduction

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

qb-dialogue's People

Contributors

liamdormon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.