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!");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}`);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:
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.
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.
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