Pool::forEachInStreamRange: Difference between revisions
(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== | ||
< | <pre> | ||
pool.forEachInStreamRange(Function callingFunction); | pool.forEachInStreamRange(Function callingFunction); | ||
</ | </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. | ||
{{ClientsideCode| | |||
<pre> | |||
< | |||
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.`); | ||
</ | </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.`);