Entity::setVariable: Difference between revisions

From RAGE Multiplayer Wiki
m (Replaced HTML with template)
(mass setting not working - clarified)
Line 21: Line 21:


<br>
<br>
This is an example of setting multiple variables to a player.
This is an example of setting multiple variables to a player which is '''not implemented and does not work (yet)'''
{{ServersideCode|
{{ServersideCode|
<pre>
<pre>

Revision as of 06:52, 21 December 2018

Set custom data to an entity.

Syntax

// To set one variable at a time
entity.setVariable(name, value);

// To set multiple variables at a time.
entity.setVariable({name1: value1, name2: value2});

Example

This binds the vehicle to the player

Server-Side
let veh = mp.vehicles.new(vehName, player.position);
player.setVariable('veh', veh);


This is an example of setting multiple variables to a player which is not implemented and does not work (yet)

Server-Side
player.setVariable({
  name: 'Player',
  age: 20
});

See More