Server Integration
Server-side exports and events for NZ Objective v1
This page covers server-side functionality for NZ Objective v1. These functions manage objective logic, persistence, and player data.
Server 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 |
Server Events
Receiving Events
| Event | Parameters | Description |
|---|---|---|
nz_objective:server:objectiveCompleted | id: string | Player completed an objective client-side |
nz_objective:server:requestObjectives | playerId: number | Client requests their objectives |
Triggering Events
| Event | Parameters | Description |
|---|---|---|
nz_objective:client:showObjective | data: table | Send objective to client for display |
nz_objective:client:hideObjective | id: string | Remove objective from client display |
nz_objective:client:updateProgress | id: string, progress: number | Update objective progress on client |
Parameter Details
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, default: 0)required:number— Amount required to complete (optional, default: 1)completed:boolean— Completion status (optional, default: false)reward:any— Reward data (optional)meta:table— Any additional metadata (optional)
Example Usage
-- Add a new objective for a player
local success = exports['nz_objective']:addObjective({
playerId = 1,
id = 'collect_apples',
title = 'Collect 5 Apples',
description = 'Find and collect 5 apples in the forest.',
progress = 0,
required = 5,
reward = { money = 100 }
})
-- Update objective progress
exports['nz_objective']:updateObjective('collect_apples', {
playerId = 1,
progress = 3
})
-- Complete an objective
exports['nz_objective']:completeObjective('collect_apples', 1)
-- Get all objectives for a player
local objectives = exports['nz_objective']:getObjectives(1)
for _, objective in pairs(objectives) do
print(objective.title, objective.progress, objective.required)
end
-- Listen for client completion
RegisterNetEvent('nz_objective:server:objectiveCompleted', function(id)
local playerId = source
exports['nz_objective']:completeObjective(id, playerId)
end)Always validate player permissions and objective ownership before updating or completing objectives.
Client Integration
Client-side exports and events for NZ Objective v1
UI Marker Overview
UI Marker is a modular, closed-source marker and zone display framework for FiveM. It provides public APIs and event hooks for creating, showing, and managing world markers and UI zones, while keeping internal logic secure.