Pool::toArray: Difference between revisions
(Created page with "This function converts pool to [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array JavaScript array]. ==Syntax== <syntaxhighlight lang="ja...") |
No edit summary |
||
| (6 intermediate revisions by 5 users not shown) | |||
| Line 1: | Line 1: | ||
This function converts pool to | __NOTOC__ | ||
{{SharedJsFunction}} | |||
{{JSContainer| | |||
==Summary== | |||
This function converts a pool to an array. | |||
{{Pool_list}} | |||
==Syntax== | ==Syntax== | ||
< | <pre> | ||
pool.toArray(); | mp.pool.toArray(); | ||
</ | </pre> | ||
==Example== | ==Example== | ||
< | {{ServersideCode| | ||
<pre> | |||
if( | const onlinePlayers = mp.players.toArray(); | ||
console.log(" | if (onlinePlayers.every(player => player.isAiming)) { | ||
</ | console.log("Everyone is aiming."); | ||
} | |||
</pre> | |||
}} | |||
}} | |||
== See Also == | |||
{{EntityPool_definition}} | |||
[[Category:Shared API]] | |||
[[Category:Shared Function]] | |||
Latest revision as of 12:17, 10 November 2024
JavaScript Syntax
Summary
This function converts a pool to an array.
Available Entity Pools
The following are the main entity pools available on the RAGEMP, used for managing various game entities:
| Entity Pool | Description |
|---|---|
| mp.players | Manages all connected players |
| mp.vehicles | Manages all spawned vehicles |
| mp.objects | Manages all created objects |
| mp.peds | Manages all non-player characters (peds) |
| mp.markers | Manages all markers in the game |
| mp.labels | Manages all 3D text labels |
| mp.checkpoints | Manages checkpoints |
| mp.blips | Manages map blips |
| mp.colshapes | Manages collision shapes |
Syntax
mp.pool.toArray();
Example
Server-Side
const onlinePlayers = mp.players.toArray();
if (onlinePlayers.every(player => player.isAiming)) {
console.log("Everyone is aiming.");
}