Pool::forEachInStreamRange: Difference between revisions
No edit summary |
mNo edit summary |
||
| Line 9: | Line 9: | ||
==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"> | <syntaxhighlight lang="javascript" highlight="3-7"> | ||
let getNicknamesText = () => { | let getNicknamesText = () => { | ||
| Line 27: | Line 26: | ||
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> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{EntityPool_Client_functions}} | {{EntityPool_Client_functions}} | ||
Revision as of 08:02, 1 September 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
Client-Side
This example will generate text with all player nicknames within the client's streaming range.
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.`);