Difference between revisions of "Players::callInDimension"

From RAGE Multiplayer Wiki
Jump to navigation Jump to search
m (Replaced HTML with template)
 
Line 2: Line 2:
  
 
==Syntax==
 
==Syntax==
<syntaxhighlight lang="javascript">
+
<pre>
 
player.callInDimension(Number dimension, String eventName [, ...args]);
 
player.callInDimension(Number dimension, String eventName [, ...args]);
</syntaxhighlight>  
+
</pre>  
 +
 
 
===Required Arguments===
 
===Required Arguments===
 
*'''dimension:''' The dimension in which the event will be sent.
 
*'''dimension:''' The dimension in which the event will be sent.
Line 13: Line 14:
 
That's example will call event added on client side for player inside the dimension ID 2 and disable regeneration health.
 
That's example will call event added on client side for player inside the dimension ID 2 and disable regeneration health.
  
<div class="header" style="background-color: #AE4040; color: #FFFFFF; border: 2px solid #AE4040;">
+
{{ClientsideCode|
<div style="margin: 10px 10px 10px 10px;"><b>Client-Side</b></div>
+
<pre>
<syntaxhighlight lang="javascript">
 
 
let disableRegeneration = () => {
 
let disableRegeneration = () => {
 
mp.game.player.setHealthRechargeMultiplier(0); //Disable regeneration
 
mp.game.player.setHealthRechargeMultiplier(0); //Disable regeneration
Line 22: Line 22:
  
 
mp.events.add('disablePlayerRegeneration', disableRegeneration);
 
mp.events.add('disablePlayerRegeneration', disableRegeneration);
</syntaxhighlight>
+
</pre>
</div>
+
}}
  
  
<div class="header" style="background-color: #408DAE; color: #FFFFFF; border: 2px solid #408DAE;">
+
{{ServersideCode|
<div style="margin: 10px 10px 10px 10px;"><b>Server-Side</b></div>
+
<pre>
<syntaxhighlight lang="javascript" highlight="4">
 
 
mp.players.callInDimension(2, "disablePlayerRegeneration");
 
mp.players.callInDimension(2, "disablePlayerRegeneration");
</syntaxhighlight>
+
</pre>
</div>
+
}}
  
  
 
==See Also==
 
==See Also==
 
{{Player_block}}
 
{{Player_block}}

Latest revision as of 12:27, 26 October 2018

This function call added client-side event for any players in a specific dimension.

Syntax

player.callInDimension(Number dimension, String eventName [, ...args]);

Required Arguments

  • dimension: The dimension in which the event will be sent.
  • eventName: Event name, what will be called.
  • args: Any arguments, what should be sended to client. Supports entities, strings, numbers and booleans. (Objects and Arrays should be packed to JSON format.)

Example

That's example will call event added on client side for player inside the dimension ID 2 and disable regeneration health.

Client-Side
let disableRegeneration = () => {
	mp.game.player.setHealthRechargeMultiplier(0); //Disable regeneration
	mp.gui.chat.push("Regeneration disabled"); //Output text to default chatbox
};

mp.events.add('disablePlayerRegeneration', disableRegeneration);


Server-Side
mp.players.callInDimension(2, "disablePlayerRegeneration");


See Also