NightZoom LogoNightZoom

API Reference

Public exports and events for NZ Objective v1 integration

Server Exports

Server-side functions for managing objective logic and persistence.

Exports

ExportParametersReturnsDescription
addObjective(data)data: tablebooleanAdds a new objective for a player
updateObjective(id, data)id: string, data: tablebooleanUpdates an existing objective by id
removeObjective(id)id: stringbooleanRemoves an objective by id
getObjectives(playerId)playerId: numbertableReturns all objectives for a player
completeObjective(id, playerId)id: string, playerId: numberbooleanMarks an objective as completed

Client Exports

Client-side functions for UI display and state management.

ExportParametersReturnsDescription
showObjective(data)data: tablevoidDisplays an objective on the client UI
hideObjective(id)id: stringvoidHides an objective from the client UI
updateObjectiveProgress(id, progress)id: string, progress: numbervoidUpdates objective progress display

System Overview

NZ Objective provides a client-server objective system with UI components.

  • Server: Manages objective logic, persistence, and validation
  • Client: Handles UI display and user interactions
  • Communication: Uses events for real-time updates between client and server

Integration Pattern

  1. Server creates/updates objectives using exports
  2. Server sends objective data to client via events
  3. Client displays objectives in UI
  4. Client reports completion back to server

For detailed integration examples, see the Client Integration and Server Integration pages.

Parameter Details

Server Functions

addObjective / updateObjective

  • data: table with the following fields:
    • playerId: number — Target player ID
    • id: string — Unique objective ID (required for update)
    • title: string — Objective title
    • description: string — Objective description
    • progress: number — Current progress (optional)
    • required: number — Amount required to complete (optional)
    • completed: boolean — Completion status (optional)
    • reward: any — Reward data (optional)
    • meta: table — Any additional metadata (optional)

removeObjective

  • id: Unique objective ID (string)

getObjectives

  • playerId: Player's server ID (number)

Example Data Structure

{
  playerId = 1,
  id = 'collect_apples',
  title = 'Collect 5 Apples',
  description = 'Find and collect 5 apples in the forest.',
  progress = 0,
  required = 5,
  completed = false,
  reward = { money = 100 },
  meta = { zone = 'forest' }
}

Events

EventParametersDescription
nz_objective:client:objectiveAddedobjective: tableFired when an objective is added
nz_objective:client:objectiveUpdatedobjective: tableFired when an objective is updated
nz_objective:client:objectiveCompletedobjective: tableFired when an objective is completed
nz_objective:client:objectiveRemovedobjective: tableFired when an objective is removed

Example Usage

-- Add an objective for a player
exports['nz_objective']:addObjective({
    playerId = 1,
    title = 'Collect 5 Apples',
    description = 'Find and collect 5 apples in the forest.',
    progress = 0,
    required = 5
})

-- Listen for objective completion
RegisterNetEvent('nz_objective:client:objectiveCompleted', function(objective)
    print('Objective completed:', objective.title)
end)

For advanced use cases, contact the development team for guidance on safe integration.