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