N.checkpoint β€” ServerCheckpoint Creator

`N.checkpoint` is a powerful, structured system for creating and managing checkpoints on the server. Each checkpoint is registered inside `N.checkpoint.list`, allowing you to track, remove, or modif

It supports:

  • βœ… Custom radius, color, and dimension

  • βœ… Enter/Exit callbacks

  • βœ… One-time triggers (once)

  • βœ… Player cooldowns

  • βœ… Internal storage for all active checkpoints

πŸ”Ή Basic Example

const jobStart = N.checkpoint.create({
  id: "job_start",
  pos: { x: 215.5, y: -810.2, z: 30.7 },
  color: [0, 255, 0, 150],
  radius: 2.0,
  dimension: 0,
  once: false,
  cooldown: 5000, // 5s per-player cooldown
  onEnter: (player) => {
    player.notify("🦺 Press E to start your job!");
  },
  onExit: (player) => {
    player.notify("πŸ‘‹ You left the job zone.");
  }
});

βœ… NurJS will:

  • Create a checkpoint with the specified position, color, and radius

  • Save it inside N.checkpoint.list

  • Automatically handle entry/exit events for all players

βš™οΈ Parameters

Option
Type
Default
Description

id

string

auto-generated

Unique checkpoint ID (cp_...).

pos

object

β€”

Coordinates {x, y, z} of the checkpoint.

radius

number

1.5

Detection radius.

color

array

[255,255,255,150]

RGBA color.

dimension

number

0

Dimension the checkpoint exists in.

onEnter

function(player)

β€”

Called when a player enters the checkpoint.

onExit

function(player)

β€”

Called when a player leaves the checkpoint.

once

boolean

false

If true, runs onEnter only once per player.

cooldown

number

0

Minimum time (ms) between re-triggering onEnter.

🧠 How It Works

When you call N.checkpoint.create(...), NurJS:

  1. Validates input data (pos required).

  2. Creates an internal checkpoint using mp.checkpoints.new().

  3. Stores all details (callbacks, cooldowns, player list) inside N.checkpoint.list.

  4. Automatically handles enter/exit logic via global events (playerEnterCheckpoint, playerExitCheckpoint).

You can later access or manipulate them:

🧩 Example: Mission Objective

After one entry, this checkpoint will no longer trigger again for that player.

🧱 Internal Structure

Each registered checkpoint in N.checkpoint.list looks like this:

This makes it easy to:

  • Access the checkpoint by reference

  • Track players currently inside

  • Extend functionality (e.g., auto-remove or time-based despawn)


πŸ“˜ Notes

  • All checkpoints are stored in memory and reset after a server restart.

  • Use once: true for single-use checkpoints (missions, triggers).

  • You can extend N.checkpoint with custom methods like .remove() or .clearAll() easily.

  • Optionally log creation with N.notify() for debugging:

N.checkpoint provides a fully managed system for safe, event-driven checkpoint creation. It’s ideal for missions, job zones, and event areas β€” keeping all logic centralized and reusable.

Last updated