Beispiel #1
0
        static public List <IntPtr> GetPickupObjectAddresses()
        {
            if (*_EntityPoolAddress == 0 || *_PickupObjectPoolAddress == 0)
            {
                return(new List <IntPtr>());
            }

            GenericPool *pickupPool   = (GenericPool *)(*_PickupObjectPoolAddress);
            EntityPool * entitiesPool = (EntityPool *)(*_EntityPoolAddress);

            List <IntPtr> pickupsAddresses = new List <IntPtr>();

            for (uint i = 0; i < pickupPool->size; i++)
            {
                if (entitiesPool->IsFull())
                {
                    break;
                }

                if (pickupPool->IsValid(i))
                {
                    ulong address = pickupPool->GetAddress(i);

                    if (address != 0)
                    {
                        pickupsAddresses.Add(new IntPtr((long)address));
                    }
                }
            }
            return(pickupsAddresses);
        }
Beispiel #2
0
        static public List <int> GetPickupObjectHandles()
        {
            FindEntityPoolAddress();
            FindPickupPoolAddress();

            GenericPool *pickupPool   = (GenericPool *)(_PickupObjectPoolAddress.ToPointer());
            EntityPool * entitiesPool = (EntityPool *)(_EntityPoolAddress.ToPointer());

            List <int> pickupsHandle = new List <int>();

            for (uint i = 0; i < pickupPool->size; i++)
            {
                if (entitiesPool->IsFull())
                {
                    break;
                }

                if (pickupPool->IsValid(i))
                {
                    ulong address = (ulong)pickupPool->GetAddress(i).ToInt64();

                    if (address != 0)
                    {
                        FindAddEntityToPoolFuncAddress();

                        int handle;
                        handle = _addEntToPoolFunc(address); //this somehow crashes GTA even if address contains a proper memory address value
                        pickupsHandle.Add(handle);
                    }
                }
            }
            return(pickupsHandle);
        }
Beispiel #3
0
        static public List <IntPtr> GetPickupObjectAddresses()
        {
            FindEntityPoolAddress();
            FindPickupPoolAddress();

            GenericPool *pickupPool   = (GenericPool *)(_PickupObjectPoolAddress.ToPointer());
            EntityPool * entitiesPool = (EntityPool *)(_EntityPoolAddress.ToPointer());

            List <IntPtr> pickupsHandle = new List <IntPtr>();

            for (uint i = 0; i < pickupPool->size; i++)
            {
                if (entitiesPool->IsFull())
                {
                    break;
                }

                if (pickupPool->IsValid(i))
                {
                    long address = pickupPool->GetAddress(i).ToInt64();

                    if (address != 0)
                    {
                        pickupsHandle.Add(new IntPtr(address));
                    }
                }
            }
            return(pickupsHandle);
        }
Beispiel #4
0
        static public uint GetPickupCount()
        {
            FindEntityPoolAddress();
            FindPickupPoolAddress();

            GenericPool *pickupPool = (GenericPool *)(_PickupObjectPoolAddress.ToPointer());

            uint count = 0;

            for (uint i = 0; i < pickupPool->size; i++)
            {
                if (pickupPool->IsValid(i))
                {
                    count++;
                }
            }

            return(count);
        }
        public static unsafe IList <Entity> CollectEntitiesFull()
        {
            if (bInitialized == false)
            {
                return(null);
            }

            FwPool *entityPool = (FwPool *)ScriptEntityPoolAddr;

            VehiclePool *vehiclePool = *(VehiclePool **)VehiclePoolAddr;

            GenericPool *pedPool = (GenericPool *)PedPoolAddr;

            GenericPool *objectPool = (GenericPool *)ObjectPoolAddr;

            List <Entity> list = new List <Entity>();

            for (uint i = 0; i < vehiclePool->size; i++)
            {
                if (entityPool->IsFull())
                {
                    break;
                }

                if (vehiclePool->IsValid(i))
                {
                    list.Add(new Vehicle(AddEntityToPool(vehiclePool->poolAddress[i])));
                }
            }

            for (uint i = 0; i < pedPool->size; i++)
            {
                if (entityPool->IsFull())
                {
                    break;
                }

                if (pedPool->IsValid(i))
                {
                    var address = pedPool->GetAddress(i);

                    if (address != 0)
                    {
                        list.Add(new Ped(AddEntityToPool(address)));
                    }
                }
            }

            for (uint i = 0; i < objectPool->size; i++)
            {
                if (entityPool->IsFull())
                {
                    break;
                }

                if (objectPool->IsValid(i))
                {
                    var address = objectPool->GetAddress(i);

                    if (address != 0)
                    {
                        list.Add(new Ped(AddEntityToPool(address)));
                    }
                }
            }

            return(list);
        }
        public virtual unsafe void Run()
        {
            uint         num3;
            GenericPool *poolPtr;
            EntityPool * poolPtr5;

            if (MemoryAccess._entityPoolAddress[0] == 0)
            {
                return;
            }
            else
            {
                poolPtr5 = *((EntityPool **)MemoryAccess._entityPoolAddress);
                if (this._type.HasFlag(Type.Vehicle) && (MemoryAccess._vehiclePoolAddress[0] != 0))
                {
                    VehiclePool *poolPtr4 = *((VehiclePool **)MemoryAccess._vehiclePoolAddress[0]);
                    uint         num      = 0;
                    if (0 < poolPtr4->size)
                    {
                        while (!poolPtr5.Full())
                        {
                            if (((byte)((poolPtr4->bitArray[(int)((num >> 5L) * 4L)] >> (num & 0x1f)) & 1)) != 0)
                            {
                                ulong address = (ulong)(num * 8L)[(int)poolPtr4->poolAddress];
                                if ((address != 0) && this.CheckEntity(address))
                                {
                                    this._handles.Add(*MemoryAccess._addEntityToPoolFunc(address));
                                }
                            }
                            num++;
                            if (num >= poolPtr4->size)
                            {
                                break;
                            }
                        }
                    }
                }
                if (this._type.HasFlag(Type.Ped) && (MemoryAccess._pedPoolAddress[0] != 0))
                {
                    GenericPool *poolPtr3 = *((GenericPool **)MemoryAccess._pedPoolAddress);
                    uint         i        = 0;
                    if (0 < poolPtr3->size)
                    {
                        while (!poolPtr5.Full())
                        {
                            if (poolPtr3.isValid(i))
                            {
                                ulong address = poolPtr3.getAddress(i);
                                if ((address != 0) && this.CheckEntity(address))
                                {
                                    this._handles.Add(*MemoryAccess._addEntityToPoolFunc(address));
                                }
                            }
                            i++;
                            if (i >= poolPtr3->size)
                            {
                                break;
                            }
                        }
                    }
                }
                if (this._type.HasFlag(Type.Object) && (MemoryAccess._objectPoolAddress[0] != 0))
                {
                    GenericPool *poolPtr2 = *((GenericPool **)MemoryAccess._objectPoolAddress);
                    uint         i        = 0;
                    if (0 < poolPtr2->size)
                    {
                        while (!poolPtr5.Full())
                        {
                            if (poolPtr2.isValid(i))
                            {
                                ulong address = poolPtr2.getAddress(i);
                                if ((address != 0) && this.CheckEntity(address))
                                {
                                    this._handles.Add(*MemoryAccess._addEntityToPoolFunc(address));
                                }
                            }
                            i++;
                            if (i >= poolPtr2->size)
                            {
                                break;
                            }
                        }
                    }
                }
                if (!this._type.HasFlag(Type.PickupObject) || (MemoryAccess._pickupObjectPoolAddress[0] == 0))
                {
                    return;
                }
                else
                {
                    poolPtr = *((GenericPool **)MemoryAccess._pickupObjectPoolAddress);
                    num3    = 0;
                    if (0 >= poolPtr->size)
                    {
                        return;
                    }
                }
            }
            do
            {
                while (true)
                {
                    if (poolPtr5.Full())
                    {
                        return;
                    }
                    else if (poolPtr.isValid(num3))
                    {
                        ulong num2 = poolPtr.getAddress(num3);
                        if (num2 != 0)
                        {
                            if (this._posCheck)
                            {
                                Vector3 position = new Vector3(num2[(int)((ulong)0x90L)], (num2 + ((ulong)0x90L))[(int)((ulong)4L)], (num2 + ((ulong)0x90L))[(int)((ulong)8L)]);
                                if (this._position.DistanceToSquared(position) > this._radiusSquared)
                                {
                                    break;
                                }
                            }
                            this._handles.Add(*MemoryAccess._addEntityToPoolFunc(num2));
                        }
                    }
                    break;
                }
                num3++;
            }while (num3 < poolPtr->size);
        }