NightZoom LogoNightZoom

Client Integration

This page covers client-side functionality for NZ Dialog v1. These functions handle dialog display and user interactions.

Client Exports

ExportParametersReturnsDescription
showDialog(data, cb)data: table, cb: functionvoidShows a dialog to the player with callback
closeDialog()nonevoidCloses the currently open dialog
isDialogOpen()nonebooleanReturns true if a dialog is currently open

Client Events

Receiving Events

EventParametersDescription
nz_dialog:client:showDialogdata: tableServer requests to show a dialog
nz_dialog:client:closeDialognoneServer requests to close dialog

Triggering Events

EventParametersDescription
nz_dialog:client:dialogOpeneddialogId: stringFired when a dialog is shown
nz_dialog:client:dialogCloseddialogId: stringFired when a dialog is closed
nz_dialog:client:dialogResponsedialogId: string, response: anyFired when player responds

Parameter Details

showDialog

  • data: table with the following fields:
    • id: string — Unique dialog ID
    • title: string — Dialog title
    • message: string — Dialog message/content
    • type: 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')
end

Client-side dialogs handle UI interactions only. For server-initiated dialogs, use server-side exports to trigger client display.