Skip to main content

Pool::exists

Server-side function

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

Summary​

The mp.pool.exists function checks if an entity with a specific ID exists within a pool. It returns true if the entity exists and false if it does not. This is helpful for ensuring an entity is valid before performing further operations.

Syntax​

mp.pool.exists(id)

Return value​

Returns true if the entity exists, false if it does not.

Required Arguments​

  • id/entity: Number — The entity ID or the entity itself to check in the pool.

Example​

This example checks if a specific player with ID 1500 exists in the players pool, and if so, sends them a welcome message. If not, it logs that the player is not found.

const playerID = 1500;

if (mp.players.exists(playerID)) {
const player = mp.players.at(playerID);
player.outputChatBox(`Welcome back, ${player.name}!`);
} else {
console.log(`Player with ID ${playerID} does not exist.`);
}