Hi everyone! Today I’m releasing one of my scripts, which adds a great interactivity to NPCs.
Now it is updated and supports both ESX and QBCore. It also supports custom frameworks based on ESX or QBCore.
Updates
New Update! Version 1.2.0
- With this update, you can interact with NPCs using qb-target or QBCore’s HelpText with the help of PolyZones.
Preview
Features
- Low Resmon
- Near NPC: 0.01-0.02 ms
- Otherwise: 0.00 ms
- Easy to configure
- Nested dialogues can be set
- [NEW] Now you can set both job or gang restriction to a NPC
Example Config
You can change the TextUIFunctions if you don’t want to use “zxn-helpText” (which is my another resource). Change [‘open’] and [‘close’] functions accordingly.
Config = {}
Config.newQB = true -- If your QBCore doesn't have export option, change it to false
Config.InteractKey = 38 -- [E] Key, Keys IDs can be found here: https://docs.fivem.net/docs/game-references/controls/#controls
Config.TextUI = true -- If true it'll open/close Help Text within range
Config.TextUIFunctions = {
['open'] = function(message, color, pos)
exports['zxn-helpText']:OpenHelpText(message, color, pos) -- You can change this to make it work with your Help Text script
end,
['close'] = function(message)
exports['zxn-helpText']:CloseHelpText() -- You can change this to make it work with your Help Text script
end
}
Config.CameraAnimationTime = 1000 -- Camera animation time in msec: 1000 msec = 1 second
Config.NPCs = {
{
npc = 'ig_tylerdix',
animdict = "mini@strip_club@idles@bouncer@base",
anim = "base",
name = 'Bodybuilder', -- NPC name, this has to be unique
dialog = 'What do you want big boy?', -- What ped says
coordinates = vector3(-1200.24, -1570.85, 3.61), -- Coordinates of Ped
heading = 38.38, -- Heading of Ped (needs to be decimals)
interactionDistance = 2.0, -- Maximum distance to interact NPC, suggested maximum distance is 2.5
options = { -- Maximum 5 options can be displayed at the moment
{'Can you teach me some moves?', 'rpgNPC:teachmoves', 'green', 'client'}, -- 'client' for client
-- 'server' for server (if you write something else it'll be server by default)
{"Let me ask you something.",
{
dialog = "Let's hear what you need.",
options = {
{'I need some meds.', 'rpgNPC:meds', 'input', 'client'},
{'Second nested dialog options',
{
dialog = "Second nested dialog.",
options = {
{'I need some stuff to eat.', 'rpgNPC:sandwich', 'input', 'client'},
{'Just another dialog option but red.', 'rpgNPC:notifRed', 'red', 'client'},
},
}, 'green', 'client'},
},
}, 'white', 'client'},
},
jobs = { -- Jobs that can interact with the NPC
"police",
"doctor",
},
},
{
npc = 'ig_tylerdix',
animdict = "mini@strip_club@idles@bouncer@base",
anim = "base",
name = 'Bodybuilder', -- Text under the header
dialog = 'What do you want big boy?', -- Text showm on the message bubble
coordinates = vector3(-1207.24, -1570.85, 3.61), -- coordinates of NPC
heading = 38.38, -- Heading of NPC (needs decimals, 0.0 for example)
interactionDistance = 2.5, -- From how far the player can interact with the NPC
options = { -- Maximum 5 options can be displayed at the moment
{'Can you teach me some moves?', 'rpgNPC:teachmoves', 'green', 'client'}, -- 'client' for client
-- 'server' for server (if you write something else it'll be server by default)
{"Let me ask you something.",
{
dialog = "Let's hear what you need.",
options = {
{'I need some meds.', 'rpgNPC:meds', 'input', 'client'},
{'Second nested dialog options',
{
dialog = "Second nested dialog.",
options = {
{'I need some stuff to eat.', 'rpgNPC:sandwich', 'input', 'client'},
{'Just another dialog option but red.', 'rpgNPC:notifRed', 'red', 'client'},
},
}, 'green', 'client'},
},
}, 'white', 'client'},
},
gangs = { -- Gangs that can interact with the NPC
"lostmc",
},
},
}
If you already have some ped created in other scripts, you can add these peds with a TriggerEvent.
Adding Dialogs (Example)
local coords = vector3(215.45, -808.71, 29.76)
local heading = 30.0
local ped = CreatePed(4, "s_m_m_highsec_04", coords.x, coords.y, coords.z, heading, false, true)
local tempTable = {
name = "Key master",
animdict = "mini@strip_club@idles@bouncer@base",
anim = "base",
npc = "s_m_m_highsec_04",
dialog = "What you here for?",
coordinates = coords,
heading = heading,
interactionRange = 2.0,
options = {
{'I need another pair of keys', 'vehiclekeys:server:createKeys', 'green', 'server'}, -- 'client' for client
{'I need to change lock of my car', 'vehiclekeys:server:changeLock', 'red', 'client'}, -- 'server' for server (if you write something else it'll be server by default)
{"I have questions about my car.",
{
dialog = "Sure, tell me what?",
options = {
{'When should I change my oil?', 'garage:client:oilchange', 'white', 'client'},
{'I want to buy some tires.', 'garage:server:buyTires', 'input', 'server'},
}
}, 'white', 'client'},
},
jobs = {},
}
TriggerEvent('zxn-rpgNPC:registerNPC', ped, tempTable)
Purchase
Tebex ($6.99 - Tax Excluded)