Difference between revisions of "Entity::getVariable"
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 | ||
− | {{ | + | {{ServersideCode| |
<pre> | <pre> | ||
− | + | 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> | ||
− | |||
}} | }} | ||
}} | }} |
Latest revision as of 12:45, 2 December 2019
![]() |
---|
Retrieves the custom data from the entity.
JavaScript Syntax

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}`); });