N.utils β€” Core Utility Functions

N.utils provides a set of simple but powerful helper methods used across all NurJS systems β€” for positions, random values, money formatting, and more.

These utilities work both client and server side, depending on the context.

N.utils.distance(p1, p2)

Calculates the 3D distance between two positions or players.

const dist = N.utils.distance(player.position, { x: 440, y: -981, z: 30 });
if (dist < 3) mp.gui.chat.push("βœ… You are close!");
Parameter
Type
Description

p1

mp.Player / Vector3 / {x,y,z}

First point or player

p2

mp.Player / Vector3 / {x,y,z}

Second point or player

βœ… Automatically supports both player.position and plain {x, y, z} objects. If something goes wrong, returns 999999 safely (no crash).

🎲 N.utils.random(min, max)

Returns a random integer between min and max (inclusive).\

const value = N.utils.random(1, 10);
mp.gui.chat.push(`🎲 Random number: ${value}`);
Parameter
Type
Description

min

number

Minimum value

max

number

Maximum value

βœ… Safe and integer-based β€” returns 0 if parameters are invalid.

N.utils.formatMoney(amount, suffix = "$")

Formats a number with spaces as thousand separators and appends a currency suffix.

Output:

Parameter
Type
Default
Description

amount

number

β€”

Amount to format

suffix

string

"$"

Optional currency symbol

βœ… Returns a clean readable string. If amount is invalid, returns "0$".

πŸ“ N.utils.vector(x, y, z)

Quickly creates a mp.Vector3 instance from coordinates or object.

βœ… Automatically detects if you pass an object or individual coordinates.

Parameter
Type
Description

x

number / object

X coordinate or {x,y,z}

y

number

Y coordinate (ignored if x is object)

z

number

Z coordinate (ignored if x is object)

N.utils.isNear(player, pos, radius = 3)

Checks if a player is within a given radius from a point.Checks if a player is within a given radius from a point.

Parameter
Type
Default
Description

player

mp.Player

β€”

Player to check

pos

{x,y,z}

β€”

Target position

radius

number

3

Distance threshold

βœ… Returns true if inside area, false otherwise.

🧠 Internal Implementation

πŸ’‘ Example β€” Zone Trigger

βœ… Commonly used in:

  • Checkpoints

  • Interaction zones

  • Door systems

  • Shop triggers

  • Vehicle garages

N.utils provides core helper methods used everywhere in NurJS:

  • πŸ“ Distance checks

  • 🎲 Random numbers

  • πŸ’° Money formatting

  • πŸ“ Quick vector creation

  • πŸ‘£ Proximity detection

It’s the foundation layer for all advanced systems like zones, checkpoints, and key binds.

Last updated