Difference between revisions of "Entity::getVariable"

From RAGE Multiplayer Wiki
Jump to navigation Jump to search
 
Line 10: Line 10:
 
entity.getVariable('variableName');
 
entity.getVariable('variableName');
 
</pre>
 
</pre>
 +
 +
=== Required Arguments ===
 +
*{{Required}}'''entity''': {{RageType|Object}}
 +
*{{Required}}'''name''': {{RageType|String}}
  
 
==Example==
 
==Example==
 
This example will retrieve the data from the variable 'veh' that is assigned to the player
 
This example will retrieve the data from the variable 'veh' that is assigned to the player
{{SharedCode|
+
{{ServersideCode|
 
<pre>
 
<pre>
let veh = player.getVariable('veh');
+
mp.events.addCommand('setNick', (player, nickname) => {
 +
  player.setVariable('oldNick', player.name);
 +
  player.name = nickname;
 +
  player.setVariable('newNick', nickname);
 +
  console.log(`Player[${player.id}] Changed nick from ${player.getVariable('oldNick')} to ${player.name}`);
 +
});
 
</pre>
 
</pre>
</div>
 
 
}}
 
}}
 
}}
 
}}

Latest revision as of 12:45, 2 December 2019


Shared
Function

Js.png JavaScript


Retrieves the custom data from the entity.

JavaScript Syntax
Jslogo.png

Syntax

entity.getVariable('variableName');

Required Arguments

  • *entity: Object
  • *name: String

Example

This example will retrieve the data from the variable 'veh' that is assigned to the player

Server-Side
mp.events.addCommand('setNick', (player, nickname) => {
  player.setVariable('oldNick', player.name);
  player.name = nickname;
  player.setVariable('newNick', nickname);
  console.log(`Player[${player.id}] Changed nick from ${player.getVariable('oldNick')} to ${player.name}`);
});


See More