Client Integration
This page covers client-side functionality for NZ Dialog v1. These functions handle dialog display and user interactions.
Client Exports
| Export | Parameters | Returns | Description |
|---|---|---|---|
showDialog(data, cb) | data: table, cb: function | void | Shows a dialog to the player with callback |
closeDialog() | none | void | Closes the currently open dialog |
isDialogOpen() | none | boolean | Returns true if a dialog is currently open |
Client Events
Receiving Events
| Event | Parameters | Description |
|---|---|---|
nz_dialog:client:showDialog | data: table | Server requests to show a dialog |
nz_dialog:client:closeDialog | none | Server requests to close dialog |
Triggering Events
| Event | Parameters | Description |
|---|---|---|
nz_dialog:client:dialogOpened | dialogId: string | Fired when a dialog is shown |
nz_dialog:client:dialogClosed | dialogId: string | Fired when a dialog is closed |
nz_dialog:client:dialogResponse | dialogId: string, response: any | Fired when player responds |
Parameter Details
showDialog
data: table with the following fields:id:string— Unique dialog IDtitle:string— Dialog titlemessage:string— Dialog message/contenttype:string— Dialog type ('confirm', 'input', 'select', etc.)options:table— Array of option objects (for select dialogs)placeholder:string— Input placeholder (for input dialogs)
cb: callback function that receives the player's response
Example Usage
-- Show a confirmation dialog
exports['nz_dialog']:showDialog({
id = 'confirm_purchase',
title = 'Confirm Purchase',
message = 'Are you sure you want to buy this item for $500?',
type = 'confirm'
}, function(response)
if response then
print('Player confirmed purchase')
else
print('Player cancelled purchase')
end
end)
-- Show an input dialog
exports['nz_dialog']:showDialog({
id = 'player_name',
title = 'Enter Name',
message = 'Please enter your character name:',
type = 'input',
placeholder = 'Your name here...'
}, function(response)
if response then
print('Player entered:', response)
end
end)
-- Listen for dialog events
RegisterNetEvent('nz_dialog:client:dialogOpened', function(dialogId)
print('Dialog opened:', dialogId)
end)
-- Check if dialog is open
if exports['nz_dialog']:isDialogOpen() then
print('A dialog is currently open')
endClient-side dialogs handle UI interactions only. For server-initiated dialogs, use server-side exports to trigger client display.