🤠 Wild Country Libs
Client API

Dialogue (NUI)

Multi-step trust conversations and simple accept/decline prompts rendered in a RedM-styled NUI panel. Extracted and generalized from wc_encounter — uses wcdialogue: message types to avoid collisions when multiple Green Studio resources are running.

RunDialogue(def, npcPed, timeoutSecs, opts) → stringclient

Runs a multi-step trust conversation. Returns "success" (trust ≥ 70), "partial" (trust ≥ 40), or "fail".

ParamTypeDescription
def.headerstringPanel title.
def.npcNamestringNPC display name.
def.trustLabelstringLabel on the trust bar. Defaults to "Trust".
def.introtable{ text, mood } — opening NPC line.
def.stepstableArray of step tables, each with an options array of { text, nextStep, trustChange, mood, response }.
timeoutSecsnumber | nilAuto-fail timeout in seconds. Defaults to 60.
opts.skipFaceEachOtherbooleanSkip the face-each-other setup step.
opts.skipNpcGesturesbooleanSuppress NPC conversation gestures.
opts.skipPlayerGesturesbooleanSuppress player conversation gestures.
RunAccept(def, npcPed, opts) → booleanclient

Simple accept/decline prompt. Returns true if the player accepted.

ParamTypeDescription
def.headerstringPanel title.
def.npcNamestringNPC display name.
def.introtable{ text, mood } — NPC opening line.
def.options.accepttable{ text } — accept button label.
def.options.declinetable{ text } — decline button label.
npcPednumberEntity handle of the NPC.
optstable | nilSame skip flags as RunDialogue.
WatchIgnore(guard, npcPed, distance, onIgnored)client

Fires onIgnored() if the player walks more than distance metres from npcPed while guard.done is false. Set guard.done = true when the encounter ends to cleanly stop the thread.

ParamTypeDescription
guardtableShared state table. Set guard.done = true to stop watching.
npcPednumberEntity handle of the NPC to watch.
distancenumber | nilWalk-away threshold in metres. Defaults to 80.
onIgnoredfunctionCallback fired when the player walks away.
example
-- Accept/decline prompt
local accepted = wc:RunAccept({
  header  = 'Stranger',
  npcName = 'Old Pete',
  intro   = { text = 'I need help haulin\' my wagon. You up for it?', mood = 'hopeful' },
  options = {
    accept  = { text = 'Sure, I can help.' },
    decline = { text = 'Not today, friend.' },
  },
}, npcPed)

if not accepted then return end

-- Multi-step trust dialogue
local result = WCLib.RunDialogue({
  header     = 'Negotiation',
  npcName    = 'Old Pete',
  trustLabel = 'Trust',
  intro      = { text = 'Right then. About the pay...', mood = 'neutral' },
  steps = {{
    options = {
      { text = 'Fair enough. What\'re you offerin\'?', trustChange = 10,  mood = 'friendly', response = 'Fifty cents and no trouble.' },
      { text = 'I want double.',                       trustChange = -15, mood = 'doubtful', response = 'You sure about that, stranger?' },
    }
  }}
}, npcPed, 45)

print('Dialogue result:', result)  -- "success", "partial", or "fail"
Message type prefix. The NUI panel uses wcdialogue: prefixed message types. If you previously used wc_encounter's encounter: types directly, update your JS accordingly.

Real Wild County example — trader NPC haggling

wc_trader/client/main.lua
local result = wc:RunDialogue({
  header  = 'The Fence',
  npcName = 'Silas',
  intro   = { text = "Got somethin' for me?", mood = 'neutral' },
  steps   = { { options = HaggleOptions } },
}, fencePed, 40)

if result == 'success' then
  TriggerServerEvent('wc_trader:sellAtBestPrice')
elseif result == 'partial' then
  TriggerServerEvent('wc_trader:sellAtFairPrice')
else
  wc:Notify({ variant = 'fail', title = "Silas isn't interested." })
end

Common mistakes

Troubleshooting