Pool::toArray: Difference between revisions
m (Cleaned up the example code's grammar, punctuation, and capitalization.) |
MrPancakers2 (talk | contribs) No edit summary |
||
| Line 1: | Line 1: | ||
This function converts a pool to a [ | __NOTOC__ | ||
{{SharedJsFunction}} | |||
This function converts a pool to an array. If you don't need to create a new array every time, use [[Pool::toArrayFast]]. | |||
{{JSContainer| | |||
==Syntax== | ==Syntax== | ||
<pre> | <pre> | ||
pool.toArray(); | mp.pool.toArray(); | ||
</pre> | </pre> | ||
| Line 9: | Line 13: | ||
{{ServersideCode| | {{ServersideCode| | ||
<pre> | <pre> | ||
const onlinePlayers = mp.players.toArray(); | |||
if( | if(onlinePlayers.every((player) => { return player.isAiming; } )) | ||
console.log("Everyone is aiming."); | console.log("Everyone is aiming."); | ||
</pre> | </pre> | ||
}} | }} | ||
}} | |||
== See Also == | |||
{{EntityPool_definition}} | |||
[[Category:Shared API]] | |||
[[Category:Shared Function]] | |||
Revision as of 02:07, 25 April 2021
This function converts a pool to an array. If you don't need to create a new array every time, use Pool::toArrayFast.
JavaScript Syntax
Syntax
mp.pool.toArray();
Example
Server-Side
const onlinePlayers = mp.players.toArray();
if(onlinePlayers.every((player) => { return player.isAiming; } ))
console.log("Everyone is aiming.");