API Reference
Public exports and events for NZ Objective v1 integration
Server Exports
Server-side functions for managing objective logic and persistence.
Exports
| Export | Parameters | Returns | Description |
|---|---|---|---|
addObjective(data) | data: table | boolean | Adds a new objective for a player |
updateObjective(id, data) | id: string, data: table | boolean | Updates an existing objective by id |
removeObjective(id) | id: string | boolean | Removes an objective by id |
getObjectives(playerId) | playerId: number | table | Returns all objectives for a player |
completeObjective(id, playerId) | id: string, playerId: number | boolean | Marks an objective as completed |
Client Exports
Client-side functions for UI display and state management.
| Export | Parameters | Returns | Description |
|---|---|---|---|
showObjective(data) | data: table | void | Displays an objective on the client UI |
hideObjective(id) | id: string | void | Hides an objective from the client UI |
updateObjectiveProgress(id, progress) | id: string, progress: number | void | Updates 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
- Server creates/updates objectives using exports
- Server sends objective data to client via events
- Client displays objectives in UI
- 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 IDid:string— Unique objective ID (required for update)title:string— Objective titledescription:string— Objective descriptionprogress: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
| Event | Parameters | Description |
|---|---|---|
nz_objective:client:objectiveAdded | objective: table | Fired when an objective is added |
nz_objective:client:objectiveUpdated | objective: table | Fired when an objective is updated |
nz_objective:client:objectiveCompleted | objective: table | Fired when an objective is completed |
nz_objective:client:objectiveRemoved | objective: table | Fired 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.