N.notify — Server Notification System

`N.notify()` is a universal system that handles **all types of notifications** — on-screen messages, chat, console logs, file logs, database entries, and even sound feedback. It’s designed to replac

🔹 Basic Syntax

dN.notify({
  player,     // optional target player
  msg,        // screen message
  chat,       // chat message
  log,        // console message
  type,       // "success" | "error" | "warn" | "info"
  prefix,     // custom prefix (e.g. "[GARAGE]")
  color,      // chat color (CSS-like)
  file,       // false | true | "logs/custom.log"
  db,         // log to DB (if N.logToDB exists)
  sound,      // play sound on client
  target,     // "all" to send to everyone
  cooldown,   // anti-spam timer in ms
});

🧠 How It Works

NurJS automatically decides how and where to send your message:

Output Type
Description

msg

Displays an on-screen notification (player.notify(...)).

chat

Sends a colored message to the in-game chat.

log

Writes to the server console.

file

Saves the notification to a log file.

db

Stores the notification in your database (if N.logToDB exists).

sound

Plays a notification sound on the client.

target: "all"

Sends the notification to all connected players.

⚙️ Parameters

Parameter
Type
Description

player

object

Target player object. Required unless target: "all".

msg

string

Shows a screen notification to the player.

chat

string

Sends a colored message to the player’s chat.

log

string

Writes to console (and optionally to file/db).

type

string

"success", "error", "warn", or "info". Automatically adds emoji, prefix, and color.

prefix

string

Custom prefix text before messages (e.g. "[ADMIN]").

color

string

Chat color name or hex code.

target

string

"all" to send to all players.

cooldown

number

Prevents spam — limits same message per player for given cooldown.

file

boolean / string

Enables log writing. If string, defines path (e.g. "logs/payments.log").

sound

boolean

If true, plays sound via client event N:notify:sound.

db

boolean

Saves message to database using N.logToDB(player, text,

"notify").

🧩 Type Presets

Each type adds emoji, prefix, and color automatically:

Type
Emoji
Color
Prefix

success

Green

[SUCCESS]

error

Red

[ERROR]

warn

⚠️

Orange

[WARN]

info

ℹ️

Cyan

[INFO]

→ shows ✅ Vehicle spawned successfully! on screen and logs [SUCCESS] Vehicle spawned successfully!.

💬 Examples

🔹 Notify Specific Player

🔹 Broadcast to All Players

Sends a chat message to everyone online.

🔹 Log to File

Automatically creates the folder and writes the log with a timestamp:

🔹 Log to Database

If your project implements N.logToDB, you can record important actions directly into your DB:

🔹 Custom Template (Global Style)

You can override the message formatting using a global config function:

Now all notifications automatically include your project prefix.

🔹 Anti-Spam Cooldown

🧠 Debug & Auto Path Protection

  • If a log file path includes "packages", NurJS automatically moves it to a safe location (/logs/notify.log) to avoid permission issues.

  • Missing folders are created automatically.

  • All errors are caught and logged safely ([N.notify] Error: ...).

N.notify() unifies all message systems — screen, chat, log, file, database, and sound — into one single, powerful function.

It’s your universal communication layer for everything that happens in the game world.

Last updated