Skip to main content

Pool::length

Summary​

This property is used to get the element count of a pool.

Note: this property is read-only.

Available Entity Pools​

The following are the main entity pools available on the RAGEMP, used for managing various game entities:

Entity PoolDescription
mp.playersManages all connected players
mp.vehiclesManages all spawned vehicles
mp.objectsManages all created objects
mp.pedsManages all non-player characters (peds)
mp.markersManages all markers in the game
mp.labelsManages all 3D text labels
mp.checkpointsManages checkpoints
mp.blipsManages map blips
mp.colshapesManages collision shapes

Syntax​

Number pool.length;

Example​

This example will return the count of vehicles and players, along with the number of "stuff" (if required entities are tracked):

Server-Side

let getEntityCounts = () => {
return {
players: mp.players.length,
vehicles: mp.vehicles.length,
objects: mp.objects.length,
markers: mp.markers.length
};
};

let { players, vehicles, objects, markers } = getEntityCounts();
console.log(`The server has ${players} players, ${vehicles} vehicles, ${objects} objects, and ${markers} markers.`);