Interactive blocks

N.bind() allows you to easily bind actions to keys, with full support for:

  • βœ… Custom key actions

  • βœ… Engine/lock toggles

  • βœ… Door control systems

  • βœ… Zone-based key logic

  • βœ… Cooldowns

  • βœ… Animations and scenarios

  • βœ… Teleportation to map marker

  • βœ… Safe (error-protected) execution

This system makes your key interactions extremely simple and powerful.

πŸ”Ή Basic Syntax

N.bind({
  key: "E",
  description: "Interact with nearest object",
  notify: "πŸ•Ή Interact key pressed",
  cooldown: 2000, // 2s cooldown
  action: (player) => {
    mp.gui.chat.push("βœ… You pressed E!");
  }
});

βœ… Automatically:

  • Binds the key "E"

  • Handles cooldown between presses

  • Shows notification if provided

  • Executes your callback safely

βš™οΈ Parameters

Option
Type
Default
Description

key

string

β€”

Main key to bind (e.g. "E", "F7", "L", "G").

engineKey

string

β€”

Binds a key to toggle vehicle engine (automatic logic).

lockKey

string

β€”

Binds a key to lock/unlock the current vehicle.

description

string

β€”

Description shown when key is registered.

notify

string

β€”

Chat notification when the key is pressed.

log

string

β€”

Console log message when triggered.

playAnim

object

null

{ dict, name } animation played on press.

playerScenario

string

null

GTA scenario name (e.g. "WORLD_HUMAN_SMOKING").

tpToMarker

boolean

false

Teleports player to map marker (calls remote event).

safe

boolean

false

Wraps the action in try/catch to prevent crashes.

doorControl

object / array

null

Opens/closes nearby doors based on config.

zone

object

null

{ pos, radius } β€” only triggers inside area.

cooldown

number

0

Time (ms) before key can be pressed again.

action

function

β€”

Function executed when the key is pressed.

🧩 Example β€” Vehicle Engine Key

βœ… Automatically toggles the player’s vehicle engine:

  • Turns the engine on/off properly using vehicle.setEngineOn()

  • Prevents auto-starting when player enters

🧩 Example β€” Vehicle Lock Key

βœ… Toggles the vehicle’s lock state:

  • Uses vehicle variable "locked"

  • Safe for both driver and passengers

🧩 Example β€” Door Control System

βœ… Automatically:

  • Detects nearby door by distance

  • Sends access check to server if checker exists

  • Toggles door open/close via mp.game.object.doorControl()

  • Plays optional notification or callback action

Server will respond using event:

🧩 Example β€” Zone-Based Key

βœ… Runs only when the player is inside the given radius.

🧩 Example β€” Teleport to Marker

Automatically teleports the player to the map waypoint (via remote event).

🧩 Example β€” Animation or Scenario Bind

Or use a scenario:

🧠 Safe Mode & Cooldowns

All binds support safe mode and cooldowns:

βœ… Prevents crashing the client and limits spam to once every 5 seconds.

πŸ“˜ Internal Behavior

Internally, N.bind():

  • Converts key names to key codes via mp.keys.getCodeFromName()

  • Uses mp.keys.bind(code, false, handler)

  • Tracks per-key cooldowns

  • Supports multiple logic layers (door control, engine toggle, zone check, etc.)

  • Uses a unified executeSafe() wrapper to handle:

    • Logging

    • Animations/scenarios

    • Teleportation

    • Notifications

    • Exception safety

🧱 Example: Combined Door + Zone + Animation

One key β†’ animation + door control + safe checks + cooldowns. That’s the full power of NurJS bindings πŸ’ͺ

N.bind() gives developers a unified and safe system for key interactions. From teleportation and vehicle logic to door systems and animations β€” everything can be attached to a single key with a few lines of code.

It’s the foundation for client gameplay interactivity in NurJS.

Last updated