Bridge is in a state of development and is not stable.
RAGE:MP to FiveM Bridge
Server

Entities, Pools, and World

Working with players, vehicles, world state, synced variables, dimensions, and security-sensitive methods.

Entities, Pools, and World

Use this page when you are working with RAGE-compatible entities, entity pools, synced entity data, global world state, routing buckets, or security-sensitive player methods.

Bridge behavior

The bridge maps RAGE-style server APIs onto FiveM primitives where possible. Some APIs, like dimensions and entity variables, are backed by FiveM routing buckets and state bags.

Use `netId` for cross-side vehicle references

When you send a vehicle across a client-server boundary, pass vehicle.netId instead of vehicle.id. The id value is side-local, so the other side cannot reliably resolve it.

Entity variables

Sync custom state on players, vehicles, and other entities using helpers or the data proxy.

World state

Control weather, time, IPLs, and traffic-light state through mp.world.

Security-sensitive calls

Remote eval and native invoke are blocked by default unless explicitly enabled with convars.

Dimensions

Dimensions map to FiveM routing buckets. Use them carefully to avoid unnecessary memory overhead.

Vehicle orphan mode

mp.vehicles supports getting and setting an entity orphan mode with .orphanMode.

The orphan mode controls what the server should do with an entity when ownership or relevancy changes.

Safe to set immediately after creation

Setting .orphanMode (or passing the orphanMode option to mp.vehicles.new, or calling setOrphanMode()) right after spawning a vehicle is safe. The underlying SET_ENTITY_ORPHAN_MODE native resolves the entity through the server game state and throws Tried to access invalid entity if it runs on a freshly created vehicle that is not networked yet. The bridge guards against this: if the vehicle already has a network id the native is applied immediately, otherwise it is deferred internally until the vehicle becomes networked and then applied with the latest value you set. You do not need to wait or poll for the network id yourself.

Set vehicle orphan mode
const vehicle = mp.vehicles.new(
  mp.joaat('adder'),
  new mp.Vector3(0, 0, 72),
  {
    heading: 0,
    dimension: 0,
  },
);

vehicle.orphanMode = EntityOrphanMode.KeepEntity;

console.log(vehicle.orphanMode);
EntityOrphanMode
enum EntityOrphanMode {
  // Default, this will delete the entity when it isn't relevant to any players
  // NOTE: this doesn't mean when they're no longer in scope
  DeleteWhenNotRelevant = 0,

  // The entity will be deleted whenever its original owner disconnects
  // NOTE: if this is set when the entity's original owner has already left it,
  // it will be marked for deletion, similar to calling DELETE_ENTITY
  DeleteOnOwnerDisconnect = 1,

  // The entity will never be deleted by the server when it does relevancy checks.
  // You should only use this on entities that need to be relatively persistent.
  KeepEntity = 2,
}

Use persistent entities intentionally

KeepEntity is useful for vehicles or world objects that should survive relevancy checks, but it also means your script is responsible for cleanup.

Entity variables

Every entity supports variable helpers for synced data.

setVariable

Set one synced key on an entity.

getVariable

Read one synced key from an entity.

setVariables

Apply multiple synced keys from an object.

data proxy

Use entity.data.someKey = value as a convenient proxy.

Entity variable helpers
player.setVariable('isReady', true);
player.setVariable('job', 'mechanic');

const isReady = player.getVariable<boolean>('isReady');

vehicle.setVariables({
  fuel: 87,
  locked: false,
  ownerId: player.id,
});
entity.data proxy
player.data.isReady = true;
player.data.job = 'mechanic';

vehicle.data.fuel = 87;
vehicle.data.locked = false;

console.log(player.data.job);
console.log(vehicle.data.fuel);
React to synced data changes
mp.events.add('entityDataChange', (entity, key, newValue, oldValue) => {
  console.log(`${entity.id} changed ${key}`, {
    oldValue,
    newValue,
  });
});

State bags under the hood

Entity variables are synchronized through FiveM state bags. Treat them as networked state, not as a replacement for local-only runtime variables.

World API

mp.world exposes global world-state helpers.

When a player becomes ready, the server pushes the current weather and time so the client starts with the correct world state.

Player spawn, auto spawn, and auto respawn

player.spawn(position, heading?) supports an optional heading parameter, matching the RAGE:MP usage shape.

player.setAutoSpawn(state) controls default client auto-spawn for that player.

player.autoRespawnAfterDeath and player.setAutoRespawnAfterDeath(enabled) control whether the player should automatically respawn after death.

Spawn with optional heading
player.spawn(new mp.Vector3(0, 0, 72));
player.spawn(new mp.Vector3(0, 0, 72), 180);
Disable default auto-spawn for interactive login
mp.events.add('playerReady', (player) => {
  // Prevent default client auto-spawn while the player is in login flow.
  player.setAutoSpawn(false);
});
Spawn after login (no intermediate 0,0,72 spawn)
function completeLogin(player: PlayerMp) {
  player.spawn(new mp.Vector3(200, -900, 30), 90);
  // or:
  // player.position = new mp.Vector3(200, -900, 30);
}
Control auto respawn after death
player.setAutoRespawnAfterDeath(true);

console.log(player.autoRespawnAfterDeath); // true

player.setAutoRespawnAfterDeath(false);
console.log(player.autoRespawnAfterDeath); // false
Spawn + auto-respawn policy
player.spawn(new mp.Vector3(200, -900, 30), 90);
player.setAutoRespawnAfterDeath(true);

Behavior overview

Use setAutoSpawn(false) at playerReady/connect when your login flow should fully control first spawn, then spawn or move the player after login to avoid an intermediate 0,0,72 spawn.

Use autoRespawnAfterDeath to check whether automatic respawn is enabled, and use setAutoRespawnAfterDeath to change it.

Security-sensitive methods

player.eval(code) and player.invoke(hash, ...) send remote execution requests to the client.

Disabled by default

Clients block remote eval and remote invoke unless the matching convars are enabled. Keep both disabled unless your project has a specific, audited reason to enable them.

By default, remote eval and remote invoke requests are rejected by the client.

This is the safest mode and should be used for production servers unless you fully control the call sites and client scripts.

Security-sensitive examples
// Sends code to the client for execution.
player.eval('mp.gui.chat.push("Hello from server")');

// Sends a native invocation request to the client.
player.invoke('0xD80958FC74E988A6', player.handle);

Dimension reminder

Dimensions map to FiveM routing buckets.

Avoid excessive bucket usage

Routing buckets are powerful, but excessive bucket usage can increase memory overhead. Prefer reusing dimensions for logical groups instead of creating many short-lived buckets.

Set an entity dimension
player.dimension = 10;
vehicle.dimension = 10;

console.log(player.dimension);

Use entity variables for state that must be synced to clients.

Use local script variables for server-only runtime state.

Use mp.world for global world state such as weather, time, IPLs, and traffic lights.

Keep remote eval and remote invoke disabled unless required and reviewed.

Use dimensions intentionally because each dimension maps to a FiveM routing bucket.

Quick reference

AreaAPINotes
Vehicle orphan modevehicle.orphanModeControls cleanup behavior when relevancy or ownership changes
Single entity variableentity.setVariable(key, value)Sets one synced key
Read entity variableentity.getVariable(key)Reads one synced key
Multiple variablesentity.setVariables(object)Applies multiple synced keys
Data proxyentity.data.key = valueConvenient synced data syntax
Weathermp.world.weatherReads or updates current weather
Timemp.world.timeSupports hour, minute, second, and set
Traffic lightsmp.world.trafficLightsSupports locked and state
IPLsrequestIpl, removeIplLoads or unloads IPLs
Spawnplayer.spawn(position, heading?)heading is optional
Set auto spawnplayer.setAutoSpawn(state)Enables or disables default client auto-spawn for this player
Auto respawnplayer.autoRespawnAfterDeathReturns whether auto respawn is enabled
Set auto respawnplayer.setAutoRespawnAfterDeath(enabled)Enables or disables auto respawn after death
Remote evalplayer.eval(code)Requires ragemp_allow_remote_eval 1
Remote invokeplayer.invoke(hash, ...)Requires ragemp_allow_remote_invoke 1
Dimensionsentity.dimensionMaps to FiveM routing buckets

On this page