RedM Natives

GET_GAME_POOL

Returns a list of entity handles (script GUID) for all entities in the specified pool - the data returned is an array as Supported pools

Hash0x2B9D4F50
Runtime nameGetGamePool
NamespaceCFX
SideClient + server
NameOfficial
Docs

Signature

object GET_GAME_POOL(char* poolName);

Parameters

NameTypeDescription
poolNamechar*

The pool name to get a list of entities from.

Returns object — An array containing entity handles for each entity in the named pool.

Description

Cfx.re native reference

Returns a list of entity handles (script GUID) for all entities in the specified pool - the data returned is an array as follows:

[ 770, 1026, 1282, 1538, 1794, 2050, 2306, 2562, 2818, 3074, 3330, 3586, 3842, 4098, 4354, 4610, ...]

Supported pools

  • CPed: Peds (including animals) and players.
  • CObject: Objects (props), doors, and projectiles.
  • CNetObject: Networked objects
  • CVehicle: Vehicles.
  • CPickup: Pickups.

Usage

Lua
local retval = GetGamePool(poolName)

-- always works, by hash
local retval = Citizen.InvokeNative(0x2b9d4f50, poolName, Citizen.ResultAsObject2(msgpack.unpack))
JavaScript and C#
JavaScript
const retval = GetGamePool(poolName);

// by hash
const retval = Citizen.invokeNative('0x2b9d4f50', poolName, Citizen.returnResultAnyway(), Citizen.resultAsObject2());
C#
Function.Call((Hash)0x2b9d4f50, poolName);

Examples

LUA · Cfx.re native reference
local vehiclePool = GetGamePool('CVehicle') -- Get the list of vehicles (entities) from the pool
for i = 1, #vehiclePool do -- loop through each vehicle (entity)
    if GetPedInVehicleSeat(vehiclePool[i], -1) == 0 then
        DeleteEntity(vehiclePool[i]) -- Delete vehicles (entities) that don't have a driver
    end
end

Sources

Cfx.re native reference

Something wrong or missing? Contribute a verified note — corrections ship through pull requests.