API ReferenceGE Extensionscore
Vehicle Active Pooling
Manages pools of vehicles with active/inactive states for performance. Controls which vehicles are visible (active) based on configurable limits and distance culling.
Manages pools of vehicles with active/inactive states for performance. Controls which vehicles are visible (active) based on configurable limits and distance culling.
Public API - Manager
| Function | Signature | Description |
|---|---|---|
M.createPool | (data?) | Creates and registers a new VehPool; returns pool object |
M.deletePool | (id) | Removes a pool by id |
M.getPool | (name) | Finds a pool by its name string |
M.getPoolById | (id) | Returns a pool by its numeric id |
M.getPoolOfVeh | (vehId) | Returns the pool containing vehId + active status |
M.getAllPools | () | Returns the pools table |
M.deleteAllPools | () | Removes all pools |
VehPool Object Methods
| Method | Description |
|---|---|
pool:insertVeh(vehId, forceInsert?) | Adds a vehicle to the pool |
pool:removeVeh(vehId) | Removes a vehicle from the pool |
pool:setVeh(vehId, activate, forceInsert?) | Activates or deactivates a vehicle |
pool:setAllVehs(activate) | Activates/deactivates all vehicles |
pool:cycle(vehId1?, vehId2?) | Swaps one active for one inactive |
pool:crossCycle(otherPool, vehId1?, vehId2?) | Cycle across two different pools |
pool:setMaxActiveAmount(amount) | Sets active vehicle limit; hides excess |
pool:activateByDistanceTo(pos?, dist?) | Distance-based activation/deactivation |
pool:getVehs() | Returns all vehicle ids (active + inactive) |
pool:deletePool(keepVehicles?) | Deletes pool; optionally deletes inactive vehicles |
pool:getSceneActiveAmount(vehTypes?) | Counts active vehicles in the scene |
Hooks
| Hook | Description |
|---|---|
M.onVehicleActiveChanged | Syncs pool state when a vehicle is toggled |
M.onVehicleDestroyed | Removes destroyed vehicles from all pools |
M.onClientEndMission | Clears all pools on mission end |
M.onSerialize | Called on Serialize event |
M.onDeserialized | Called on Deserialized event |
M.logErrors | Boolean. Enables error logging (default false). |
Module State
| Variable | Type | Default |
|---|---|---|
logErrors | boolean | false |
Usage Example
local pool = core_vehicleActivePooling.createPool({
name = "trafficPool",
maxActiveAmount = 10,
poolingMode = "default"
})
-- Add vehicles
for _, veh in ipairs(myVehicles) do
pool:insertVeh(veh:getID())
end
-- Distance-based culling in onUpdate
pool:activateByDistanceTo(playerPos, 300)Trailer Respawn
Manages trailer attachment tracking, respawn placement, and vehicle train queries.
Vehicle Bridge (GE ↔ VLua Communication)
Black-box communication layer between GE Lua and vehicle Lua (VLua). All gameplay-related VLua requests should go through this bridge via `gameplayInterface` on the vehicle side.