Entity::getVariable: Difference between revisions
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
Retrieves | Retrieves a server side custom data from the entity. | ||
{{ServersideJsFunction}} | |||
{{JSContainer| | {{JSContainer| | ||
Latest revision as of 17:17, 12 September 2024
Retrieves a server side custom data from the entity.
Server-Side Function
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}`);
});