Pool::forEachInStreamRange: Difference between revisions

From RAGE Multiplayer Wiki
(Created page with "This function is used for calling a function for each element in a pool. ==Syntax== <syntaxhighlight lang="javascript"> pool.forEachInStreamRange(Function callingFunction); <...")
 
m (Replaced HTML with template)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This function is used for calling a function for each element in a pool.
This function is used for calling a function for each element that is in a client's streaming range in a pool.


==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">
<pre>
pool.forEachInStreamRange(Function callingFunction);
pool.forEachInStreamRange(Function callingFunction);
</syntaxhighlight>  
</pre>
===Required Arguments===
===Required Arguments===
*'''callingFunction:''' Function, what will be called.
*'''callingFunction:''' Function, what will be called.
Line 11: Line 12:
This example will generate text with all player nicknames within the client's streaming range.
This example will generate text with all player nicknames within the client's streaming range.


<div class="header" style="background-color: #408DAE; color: #FFFFFF; border: 2px solid #408DAE;">
{{ClientsideCode|
<div style="margin: 10px 10px 10px 10px;"><b>Server-Side</b></div>
<pre>
<syntaxhighlight lang="javascript" highlight="3-7">
let getNicknamesText = () => {
let getNicknamesText = () => {
let text = ``;
let text = ``;
Line 26: Line 26:
let blahBlah = getNicknamesText();
let blahBlah = getNicknamesText();
console.log(blahBlah != `` ? blahBlah : `There are no players in your streaming range.`);
console.log(blahBlah != `` ? blahBlah : `There are no players in your streaming range.`);
</syntaxhighlight>
</pre>
</div>
}}


==See Also==
==See Also==
{{EntityPool_Client_functions}}
{{EntityPool_Client_functions}}

Latest revision as of 13:40, 26 October 2018

This function is used for calling a function for each element that is in a client's streaming range in a pool.

Syntax

pool.forEachInStreamRange(Function callingFunction);

Required Arguments

  • callingFunction: Function, what will be called.

Example #1

This example will generate text with all player nicknames within the client's streaming range.

Client-Side
let getNicknamesText = () => {
	let text = ``;
	mp.players.forEachInStreamRange(
		(player, id) => {
			text = text == `` ? player.name : `${text} , ${player.name}`;
		}
	);
	return text;
};

let blahBlah = getNicknamesText();
console.log(blahBlah != `` ? blahBlah : `There are no players in your streaming range.`);

See Also