NPC Dialog

NPC Dialog creation and modification

Creating a NPC

        local jobNPC = nil
        
        local npc = {
            name = 'Warehouse Manager',
            details = {
                pos = vec3(0,0,0), 
                heading = 90.0,
                -- The interaction system automatically gets the hash key using joaat()
                model = '',
            },
            text = 'Sup homie, you wanna deliver some good shit to some shops?',
            menu = {
                {
                    label = "Let's go boi",
                    action = function()
                        lib.callback('shopdeliver:startJob', false, function(state)
                            if state then
                                startJob()
                            else
                                print('Failed to start job')
                            end
                        end)
                    end,
                    type = 'confirm'
                },
                {
                    label = "Nah",
                    type = 'close'
                }
            }
        }
        
        -- Returns a ID the same way as the Interactions
        jobNPC = exports['h-interactions']:registerNPC(npc)
        
        -- Remove NPC with ID
        local deleted = exports['h-interactions']:deleteNPC(jobNPC)
        
        if deleted then
            print('NPC has been deleted)
            jobNPC = nil
        end

Last updated