Entity::setOwnVariable: Difference between revisions
MrPancakers2 (talk | contribs) m (Undone translations) |
No edit summary |
||
| Line 2: | Line 2: | ||
{{ServersideJsFunction}} | {{ServersideJsFunction}} | ||
{{JSContainer| | |||
Sets the data available to the player as opposed to [[Entity::setVariable|player.setVariable(key, value)]], the data that you set with 'setOwnVariable' is only available for the given player. | |||
==Syntax== | ==Syntax== | ||
<pre> | <pre> | ||
player.setOwnVariable(key, value); | |||
</pre> | </pre> | ||
=== Required Arguments === | === Required Arguments === | ||
*{{Required}}'''key''': {{RageType|String}} | *{{Required}}'''key''': {{RageType|String}} | ||
*{{Required}}'''value''': {{RageType|Any}} | *{{Required}}'''value''': {{RageType|Any}} | ||
| Line 22: | Line 20: | ||
<pre> | <pre> | ||
player.setOwnVariable("jobId", 9); | player.setOwnVariable("jobId", 9); | ||
player.getOwnVariable("jobId"); //9 | |||
</pre> | </pre> | ||
}} | }} | ||
{{ClientsideCode| | {{ClientsideCode| | ||
<pre> | <pre> | ||
Revision as of 18:45, 29 May 2024
Server-Side Function
JavaScript Syntax
Sets the data available to the player as opposed to player.setVariable(key, value), the data that you set with 'setOwnVariable' is only available for the given player.
Syntax
player.setOwnVariable(key, value);
Required Arguments
- *key: String
- *value: Any
Example
This will set the job id for this player, which will only be available to him.
Server-Side
player.setOwnVariable("jobId", 9);
player.getOwnVariable("jobId"); //9
Client-Side
mp.players.local.getVariable("jobId"); // 9