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); <...")
 
No edit summary
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==

Revision as of 00:41, 27 June 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.

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