Entity::setVariable: Difference between revisions

From RAGE Multiplayer Wiki
(Created page with "__NOTOC__ '''Function''': Sets a custom data into an entity. ==Syntax== <syntaxhighlight lang="javascript"> entity.setVariable(name, value); </syntaxhighlight> ==Example==...")
 
Line 6: Line 6:
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
entity.setVariable(name, value);
entity.setVariable(name, value);
//best way is JSON object:
entity.setVariable({name: value});
</syntaxhighlight>
</syntaxhighlight>



Revision as of 17:04, 15 August 2018


Function: Sets a custom data into an entity.

Syntax

entity.setVariable(name, value);

//best way is JSON object:
entity.setVariable({name: value});

Example

Server-Side

// Supposed you're trying to bind a vehicle to a player, you can do this:
let veh = mp.vehicles.new(vehName, player.position);
player.setVariable('veh', veh);