Fivecore
  • Fivecore - FiveM Scripts
  • Discord
  • General
    • Common issues
  • RESOURCES
    • Zombies
      • Installation
      • Usage
      • Functions
        • Server Functions
      • Events
        • Server Events
    • Looting
      • Installation
      • Setup
      • Events
        • Server Events
      • Functions
        • Client Functions
        • Server Functions
      • Loot editor
    • NPC Dialogs
      • Installation
      • Usage
      • Extras
    • Dynamic Guides
      • Installation
      • Usage
    • Interact
      • Installation
      • Usage
      • InteractOptions
      • Functions
        • Client
Powered by GitBook
On this page
  1. RESOURCES
  2. NPC Dialogs

Usage

How to use and create NPCs

Creating your first NPC Dialog

  • Go to npc_dialog/config.lua

  • Copy this layout and add inside Config.NPCs

-- base layout
[''] = {
    name = '',
    title = '',
    description = '',
    model = '',
    coords = vector4(0.0, 0.0, 0.0),
    buttons = {
        {
            text = '',
            event = '',
            type = '',
        },
        {
            text = 'Goodbye!',
        }
    }
},
  • Create your NPC according to the example below

This is an example where all possibilities are used, most are not required and it depends on your needs.

-- example with all options available
['lester-ls'] = { -- unique name
        name = 'Lester', -- ped name
        title = 'Hey!', -- interface title
        description = 'I need a service, are you available?', -- interface description
        model = 'ig_lestercrest', -- ped model ( optional, You can see all of the here: https://docs.fivem.net/docs/game-references/ped-models/
        coords = vector4(440.99, -982.74, 30.69, 204.69), -- ped coords ( required )
        interactDistance = 2.0, -- the max distance to interact with ped ( optional, if not defined will use the default )
        -- weapon = 'weapon_assaultsmg', -- make the ped hold a weapon ( optional, https://wiki.rage.mp/index.php?title=Weapons)
        -- target = { -- optional, use if UseQBTarget config is enabled
        --    icon = 'fa-solid fa-list-check',
        --    label = 'Talk with Lester',
        -- },
        blip = { -- create a blip for the ped ( optional )
            name = "Lester Missions", -- blip name to show on map
            sprite = 458, -- blip icon, you can see all of them here: https://docs.fivem.net/docs/game-references/blips/
            color = 44, -- blip color, you can see the colors in the same website of sprites.
        },
        -- anim = {  -- You can use anim or scenario, not both ( optional )
        --     dict = 'amb@world_human_bum_slumped@male@laying_on_right_side@idle_b', -- anim dict
        --     name = 'idle_d', -- anim name
        --     flag = 46 -- anim flag
        -- },
        -- scenario = 'WORLD_HUMAN_GUARD_STAND_FACILITY', -- You can use anim or scenario, not both ( optional )
        buttons = {
            {
                text = 'I love misterous things, I will do it!', -- ( required )
                event = 'example:server:acceptMission', -- event name if you want to trigger a event ( optional )
                type = 'server', -- client, server or command ( optional )
                args = {'lester-ls'}, -- event args if needed
                confirm = 'Are you sure? You need to pay $10,000 for this!', -- shows a confirm dialog after click ( optional )
            },
            {
                text = 'It is not dangerous?', -- text of the button ( required )
                action = function () -- this is a function, you can do anything here ( client side )
                    print('You clicked on the button')
                end,
                canInteract = function()  -- with this function you can check if the button will appear or not by returning true or false
                    -- You can check if the player has a weapon for example
                    return true
                end
            },
            {
                text = 'What do you need?', -- text of the button ( required )
                open = { -- create a secondary dialogue ( optional )
                    title = 'Its a secret!', -- new interface title
                    description = 'You will receive a good amount of money for this!', -- new interface description
                    buttons = {
                        {
                            text = 'I will do it!', -- text of the button ( required )
                            event = 'questsmenu lester', -- event name if you want to trigger a event or a command ( optional )
                            type = 'command', -- client, server or command ( optional )
                        },
                        {
                            text = 'Let me think about it...', -- text of the button ( required )
                            open = 'back' -- back to main interface
                        }
                    }
                }
            },
            {
                text = 'Goodbye!', -- do nothing, only for close interaction
            }
        }
    },
PreviousInstallationNextExtras

Last updated 10 months ago