NPC DIALOG
es-npcdialog - free script
Usage Examples:
1. Basic Shop Owner Dialog with Trigger:
exports['es-xx']:ShowNPCDialog({
id = "shop_1",
name = "Shop Owner",
avatar = "path/to/avatar.png",
message = "Welcome! How can I help you?",
color = "#ffd100", -- Gold theme
options = {
{
label = "Buy Items",
value = "buy",
trigger = "es-xx:server:openShop" -- Server trigger when confirmed
},
{
label = "Sell Items",
value = "sell",
trigger = "es-xx:client:openSellMenu" -- Client trigger when confirmed
}
}
})
2. Simple Yes/No Dialog:
exports['es-xx']:ShowNPCDialog({
id = "quest_accept",
name = "Quest Master",
avatar = "path/to/avatar.png",
message = "Would you like to start this quest?",
color = "#00ff00", -- Green theme
options = {
{
label = "Yes",
value = "yes",
trigger = "es-xx:server:startQuest"
},
{
label = "No",
value = "no"
}
}
})
3. While True Do Example:
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
-- Check distance to NPC
if #(coords - vector3(1234.5, 678.9, 123.4)) < 2.0 then
if IsControlJustPressed(0, 38) then -- E key
exports['es-xx']:ShowNPCDialog({
id = "npc_talk",
name = "Guard",
avatar = "path/to/avatar.png",
message = "Halt! This area is restricted. Do you have permission?",
color = "#ff0000", -- Red theme
options = {
{
label = "Show Papers",
value = "papers",
trigger = "es-xx:server:checkPapers"
},
{
label = "Leave",
value = "leave"
}
}
})
end
-- Show floating help text
DrawText3D(1234.5, 678.9, 123.4, "Press ~y~E~w~ to talk")
end
end
end)
4. Multiple Choice with Different Triggers:
exports['es-xx']:ShowNPCDialog({
id = "trainer",
name = "Combat Trainer",
avatar = "path/to/avatar.png",
message = "What would you like to learn?",
color = "#ffd100",
options = {
{
label = "Sword Training",
value = "sword",
trigger = "es-xx:server:startTraining",
args = { type = "sword", cost = 1000 } -- Additional data to pass
},
{
label = "Archery Training",
value = "bow",
trigger = "es-xx:client:startBowTraining",
args = { difficulty = "beginner" }
},
{
label = "View Progress",
value = "progress",
trigger = "es-xx:client:showProgress"
},
{
label = "Maybe Later",
value = "cancel"
}
}
})
Last updated