N.auto.load — Server Automatic JSON Loader
`N.auto.load()` automatically spawns **vehicles**, **objects**, and other entities from a JSON configuration file. This system is designed to make your development faster — just define everything on
🔹 Basic Syntax
N.auto.load({
file: "data/vehicles.json",
log: {
path: "logs/autospawn.log",
text: "[AUTO] Created {type} model={model} pos={pos}",
type: "info"
}
});✅ NurJS will:
Read your JSON file
Parse and validate every item
Automatically create entities via
N.spawn()Log every creation to file (and optionally to console +
N.notify)
🔹 JSON Structure Example
[
{
"type": "vehicle",
"model": "sultan",
"pos": { "x": -1025.1, "y": -2735.3, "z": 20.2 },
"heading": 90,
"color": [0, 0, 0],
"engine": true,
"lock": false,
"plate": "NR-001",
"dimension": 0,
"data": { "garageId": 12 }
},
{
"type": "object",
"model": "prop_crate_11e",
"pos": { "x": 215.1, "y": -810.2, "z": 30.7 },
"dimension": 0,
"data": { "lootable": true }
}
]
✅ Supported types:
"vehicle"
Creates cars, motorcycles, or any vehicle via N.spawn("vehicle").
"object"
Creates world props via N.spawn("object").
⚙️ Parameters
file
string
Path to JSON file relative to server root (e.g. "data/vehicles.json").
log.path
string
Optional custom log file path (default "logs/auto.log").
log.text
string
Log message template — supports {type}, {model}, {pos}.
log.type
string
Message type for N.notify (e.g. "info", "success", "warn").
🔧 Example Setup
📁 Folder structure
🧠 Example index.js
Result in console:
🗂️ Logging System
Each loaded item generates a line in your log file:
At the end of the process:
---- TOTAL: 10 created, 0 skipped ----
✅ Automatic features:
Creates the
logs/folder if missing.Detects invalid items and skips them safely.
Records total results and execution time.
Optionally calls
N.notify()for visual + database logs.
🧩 Integration with N.spawn
N.auto.load() internally uses N.spawn() to create all entities.
That means it supports every option from N.spawn — like engine, plate, dimension, and variables.
🧱 Error Handling
NurJS automatically handles:
Missing or invalid file → warning in console
Invalid JSON format → safe fallback
Invalid entity data → skip without crash
Example console output:
N.auto.load() is the simplest way to bulk-load vehicles, objects, or any other world entities.
Just define them once in JSON — NurJS takes care of creation, logging, and error handling.
Last updated