Entity::setOwnVariable: Difference between revisions

From RAGE Multiplayer Wiki
(Created page with "__TOC__ {{ServersideJsFunction}} Sets the data available to the player as opposed to entity.setVariable(key, value). Устанавливает дл...")
 
 
(4 intermediate revisions by 3 users not shown)
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.


Sets the data available to the player as opposed to [[Entity::setVariable|entity.setVariable(key, value)]].
Устанавливает для игрока данные, которые доступны ему, в отличии от [[Entity::setVariable|entity.setVariable(key, value)]].
{{JSContainer|
==Syntax==
==Syntax==
<pre>
<pre>
entity.setOwnVariable(key, value);
player.setOwnVariable(key, value);
</pre>
</pre>


=== Required Arguments ===
=== Required Arguments ===
*{{Required}}'''entity''': {{RageType|Object}}
*{{Required}}'''key''': {{RageType|String}}
*{{Required}}'''name''': {{RageType|String}}
*{{Required}}'''value''': {{RageType|Any}}
*{{Required}}'''value''': {{RageType|Any}}


==Example==
==Example==
This will set the job id for this player, which will only be available to him.
This will set the job id for this player, which will only be available to him.
Это установит id работы для данного игрока, которое будет доступно только у него.
 
{{ServersideCode|
{{ServersideCode|
<pre>
<pre>
player.setOwnVariable("jobId", 9);
player.setOwnVariable("jobId", 9);
player.getOwnVariable("jobId"); //9
</pre>
</pre>
}}
}}


<br>
 
{{ClientsideCode|
{{ClientsideCode|
<pre>
<pre>
Line 35: Line 33:


== See More ==
== See More ==
{{Player_function}}
{{Entity_functions}}
{{Entity_functions}}


[[Category:Entity API]]
[[Category:Entity API]]
[[Category:Server-side Function]]
[[Category:Server-side Function]]

Latest revision as of 18:50, 29 May 2024

Server-Side
Function

 JavaScript



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


See More