Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define VehiclePoolPtr 0x01CD27C8
- #define DrawablePoolPtr 0x01C95C3C
- #define ObjectPoolPtr 0x01CE6780
- #define PedPoolPtr 0x01CEFE50
- #define PickupPlacementPoolPtr 0x01CF172C
- #define PickupPoolPtr 0x01CF1738
- #define AmmoInfoPoolPtr 0x021478E8
- #define CProjectilePoolPtr 0x02147CB8
- #define GET_ENTITY_HANDLE 0x474054
- //--- GET_ENTITY_HANDLE aka _addEntityToPoolFunc
- /*oldest pool*/
- struct CEntityPool
- {
- int* iPoolEntries; // Ptr to array of entity addresses
- int iMaxEntities; // Max number of slots in pool
- int iFreeSlots; // Free (unused) entries
- int iStructSize; // Usually 4 (stride)
- int iLastAddr; // Last valid address used
- int iActiveCount; // Optional: active count (can be filled via CountActive())
- const char* szPoolName; // Optional: for debugging and labeling
- // Accessor
- uint32_t* GetEntityAt(int index)
- {
- if (index < 0 || index >= iMaxEntities) return nullptr;
- int addr = iPoolEntries[index];
- if (addr == 0 || addr > 0x30000000) return nullptr;
- return (uint32_t*)addr;
- }
- // Safe Entity to Handle conversion (via GET_ENTITY_HANDLE func)
- int GetHandleAt(int index) //--- GET_ENTITY_HANDLE aka _addEntityToPoolFunc
- {
- uint32_t* ent = GetEntityAt(index);
- if (!ent) return 0;
- return call<int>(0x474054)(ent);
- }
- // Active counter
- int CountActive()
- {
- int count = 0;
- for (int i = 0; i < iMaxEntities; i++)
- {
- if (iPoolEntries[i] != 0 && iPoolEntries[i] < 0x30000000)
- count++;
- }
- return count;
- }
- };
- //--- Wrapper to get entity handle from raw pointer ---
- void DrawEntitiesFromPool(int pool_base, const char* label, int r, int g, int b)
- {
- if (!pool_base) {
- printf("Invalid Pool Addr for %s\n", label);
- return;
- }
- CEntityPool* pool = (CEntityPool*)pool_base;
- pool->szPoolName = label;
- if (!pool->iPoolEntries || pool->iMaxEntities <= 0 || pool->iFreeSlots < 0) {
- printf("Pool %s invalid\n", label);
- return;
- }
- printf("--- Drawing %s Pool ---\n", label);
- printf("Max: %d | Free: %d | Active: %d\n", pool->iMaxEntities, pool->iFreeSlots, pool->CountActive());
- for (int i = 0; i < pool->iMaxEntities; i++)
- {
- int handle = pool->GetHandleAt(i);
- if (handle == 0) continue;
- Vector3 ent_coords = GET_ENTITY_COORDS(handle, 1);
- Vector3 my_coords = GET_ENTITY_COORDS(PLAYER_PED_ID(), 1);
- DrawLine(my_coords, ent_coords, r, g, b, 255);
- }
- }
- //hook
- void debug_DrawAllEntities()
- {
- DrawEntitiesFromPool(*(int*)VehiclePoolPtr, "Vehicle", 255, 0, 0);
- DrawEntitiesFromPool(*(int*)PedPoolPtr, "Ped", 255, 255, 255);
- DrawEntitiesFromPool(*(int*)ObjectPoolPtr, "Object", 0, 255, 0);
- DrawEntitiesFromPool(*(int*)PickupPlacementPoolPtr, "PickupPlacement", 255, 255, 0);
- DrawEntitiesFromPool(*(int*)DrawablePoolPtr, "Drawable", 64, 64, 64);
- DrawEntitiesFromPool(*(int*)CProjectilePoolPtr, "Projectile", 255, 0, 255);
- }
Add Comment
Please, Sign In to add comment