N.event (Client) — Universal Client Event Handler

N.event() is the main client-side event system in NurJS. It simplifies registering client events while adding optional logic like notifications, animations, teleportation to marker, and safe execution.

You can trigger events from the server with player.call('eventName', [...args]) or from other client scripts.

🔹 Basic Syntax

N.event({
event: "client:test",
description: "Example of a simple client event",
notify: "💡 Client event triggered!",
log: "Event executed successfully",
tpToMarker: false,
action: (...args) => {
mp.gui.chat.push("✅ Event executed with args: " + args.join(", "));
}
});

✅ NurJS will automatically:

  • Register the event via mp.events.add(event)

  • Show a notification and console/chat log if specified

  • Handle animation, teleportation, and error safety

⚙️ Parameters

Option
Type
Default
Description

event

string

The event name (e.g. "garage.open").

description

string

Description for documentation or debugging.

notify

string

Shows on-screen notification when event triggers.

log

string

Writes to chat log (mp.gui.chat.push).

playAnim

object

null

{ dict, name } — animation to play when triggered.

playerScenario

string

null

Starts a scenario animation (e.g. "WORLD_HUMAN_SMOKING").

tpToMarker

boolean

false

Teleports player to the map marker (if set).

safe

boolean

false

Enables try/catch protection inside the action.

action

function

Core callback executed when the event is triggered.

🧩 Example 1 — Simple Client Notification

🧩 Example 2 — Play Animation on Trigger

When this event is triggered, your character plays a dance animation instantly.

🧩 Example 3 — Teleport to Map Marker

If the player has a waypoint on the map, they’ll be teleported there automatically.

🧩 Example 4 — Safe Execution Mode

✅ Instead of crashing, the client will safely display:

🧠 How It Works Internally

  • NurJS registers the event using mp.events.add(event, callback).

  • When triggered:

    • Optional notify and log are displayed.

    • Optional animation/scenario is executed.

    • Optional teleport is handled.

    • The main action runs inside a safe try/catch (if safe: true).

📘 Notes

  • You can trigger client events from the server with:

You can also call them from other client scripts:

Works perfectly together with N.bind, N.command, and N.cache.

N.event() on the client side allows you to create event-driven logic without boilerplate — adding animations, notifications, teleportation, and safe handling automatically.

It’s the foundation of all client-side interactivity in NurJS.

Last updated