Server Integration
This page covers server-side functionality for NZ Dialog v1. These functions handle server-initiated dialogs and response processing.
Server Exports
| Export | Parameters | Returns | Description |
|---|---|---|---|
showDialogToPlayer(playerId, data, cb) | playerId: number, data: table, cb: function | void | Shows a dialog to a specific player |
closeDialogForPlayer(playerId) | playerId: number | void | Closes dialog for a specific player |
showDialogToAll(data, cb) | data: table, cb: function | void | Shows a dialog to all players |
Server Events
Receiving Events
| Event | Parameters | Description |
|---|---|---|
nz_dialog:server:dialogResponse | dialogId: string, response: any | Player responded to a dialog |
Triggering Events
| Event | Parameters | Description |
|---|---|---|
nz_dialog:client:showDialog | data: table | Send dialog to client for display |
nz_dialog:client:closeDialog | none | Close dialog on client |
Parameter Details
showDialogToPlayer / showDialogToAll
playerId: Target player's server ID (number)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)timeout:number— Auto-close timeout in milliseconds (optional)
cb: callback function that receives the player's response
Example Usage
-- Show confirmation dialog to a player
exports['nz_dialog']:showDialogToPlayer(1, {
id = 'admin_confirm',
title = 'Admin Action',
message = 'Are you sure you want to kick this player?',
type = 'confirm'
}, function(response, playerId)
if response then
print('Admin confirmed action for player', playerId)
-- Perform admin action
end
end)
-- Show input dialog to player
exports['nz_dialog']:showDialogToPlayer(1, {
id = 'report_reason',
title = 'Report Player',
message = 'Please provide a reason for the report:',
type = 'input',
placeholder = 'Enter reason...'
}, function(response, playerId)
if response and response ~= '' then
print('Report reason:', response, 'from player', playerId)
-- Process report
end
end)
-- Show selection dialog to all players
exports['nz_dialog']:showDialogToAll({
id = 'server_vote',
title = 'Server Vote',
message = 'Vote for the next event:',
type = 'select',
options = {
{ label = 'Racing Event', value = 'racing' },
{ label = 'PvP Event', value = 'pvp' },
{ label = 'Roleplay Event', value = 'rp' }
}
}, function(response, playerId)
if response then
print('Player', playerId, 'voted for:', response)
-- Process vote
end
end)
-- Listen for dialog responses
RegisterNetEvent('nz_dialog:server:dialogResponse', function(dialogId, response)
local playerId = source
print('Dialog response:', dialogId, response, 'from player', playerId)
end)
-- Close dialog for a player
exports['nz_dialog']:closeDialogForPlayer(1)Always validate player permissions before showing sensitive dialogs or processing responses.
Client Integration
This page covers client-side functionality for NZ Dialog v1. These functions handle dialog display and user interactions.
NZ Objective
NZ Objective is a modular, closed-source objective and task framework for FiveM. It provides public APIs and event hooks for creating, tracking, and managing player objectives, while keeping internal logic secure.