Pool::forEachInStreamRange: Difference between revisions

From RAGE Multiplayer Wiki
mNo edit summary
m (Replaced HTML with template)
 
Line 2: Line 2:


==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.


==Example #1==  
==Example #1==  
{{ClientSide}}
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.


<syntaxhighlight lang="javascript" highlight="3-7">
{{ClientsideCode|
<pre>
let getNicknamesText = () => {
let getNicknamesText = () => {
let text = ``;
let text = ``;
Line 25: 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>
}}


==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