Pool::forEachInDimension: Difference between revisions

From RAGE Multiplayer Wiki
(Fix)
m (Replaced HTML with template)
Line 2: Line 2:


==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">
<pre>
void pool.forEachInDimension(int dimension, function callingFunction);
void pool.forEachInDimension(int dimension, function callingFunction);
</syntaxhighlight>  
</pre>  
 
===Required Arguments===
===Required Arguments===
*'''Dimension:''' Int, dimension
*'''Dimension:''' Int, dimension
Line 11: Line 12:
==Example==  
==Example==  
This example will print the names of players in dimension 0 to the server console. (Dimension 0 is the default dimension)
This example will print the names of players in dimension 0 to the server console. (Dimension 0 is the default dimension)
<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">
mp.players.forEachInDimension(0, (player, id) => {
mp.players.forEachInDimension(0, (player, id) => {
     console.log("Player: " + player.name);
     console.log("Player: " + player.name);
});
});
</syntaxhighlight>
</pre>
</div>
}}


==See Also==
==See Also==
{{EntityPool_function}}
{{EntityPool_function}}

Revision as of 12:13, 26 October 2018

This function is used to call a function for each elements in the pool.

Syntax

void pool.forEachInDimension(int dimension, function callingFunction);

Required Arguments

  • Dimension: Int, dimension
  • callingFunction: Function, what will be called.

Example

This example will print the names of players in dimension 0 to the server console. (Dimension 0 is the default dimension)

Server-Side
mp.players.forEachInDimension(0, (player, id) => {
    console.log("Player: " + player.name);
});

See Also