Help! Method Calling an Offset with a Float[] Parameter

MinimalXenon

Platinian
Hello! I was wondering what I'm doing wrong because a float[] parameter fails to get registered when im calling this method (I'm only giving an example):

Code:
void TeleportMap(int mapId, float[] position)

When I call this method it does teleport me to another map that I chose. The problem is that the position I've set doesn't register, making me go to a random coordinate in the map chosen by the game.

Through some means I found that float[] position contains the X, Y, and Z Coordinates. But still, no matter what I do, TeleportMap() refuses the new one I give.

How do I call it correctly?
 
Last edited:
Solution
the arguments or parameter of float[] is an array. You will need to use monoArray and hook it.

If you are hooking within TeleportMap:

C++:
void Hooked_TeleportMap(int mapId, monoArray<float>* position) {
    if (position) {
        int length = position->getLength();
        float* posData = position->getPointer();
        
        printf("Teleporting to Map %d at Position: [%f, %f, %f]\n",
                mapId, posData[0], posData[1], posData[2]);
    }

    // Call the original function if needed
    original_TeleportMap(mapId, position);
}

If needed to create an array, you can pass it to TeleportMap:


C++:
monoArray<float>* CreateFloatArray(int size) {
    monoArray<float>* arr =...
the arguments or parameter of float[] is an array. You will need to use monoArray and hook it.

If you are hooking within TeleportMap:

C++:
void Hooked_TeleportMap(int mapId, monoArray<float>* position) {
    if (position) {
        int length = position->getLength();
        float* posData = position->getPointer();
        
        printf("Teleporting to Map %d at Position: [%f, %f, %f]\n",
                mapId, posData[0], posData[1], posData[2]);
    }

    // Call the original function if needed
    original_TeleportMap(mapId, position);
}

If needed to create an array, you can pass it to TeleportMap:


C++:
monoArray<float>* CreateFloatArray(int size) {
    monoArray<float>* arr = (monoArray<float>*)malloc(sizeof(monoArray<float>) + sizeof(float) * size);
    arr->max_length = size;
    return arr;
}

// Example usage
monoArray<float>* pos = CreateFloatArray(3);
pos->vector[0] = 100.0f;  // X
pos->vector[1] = 50.0f;   // Y
pos->vector[2] = 200.0f;  // Z

TeleportMap(1, pos); // Call the function
 
Solution
the arguments or parameter of float[] is an array. You will need to use monoArray and hook it.

If you are hooking within TeleportMap:

C++:
void Hooked_TeleportMap(int mapId, monoArray<float>* position) {
    if (position) {
        int length = position->getLength();
        float* posData = position->getPointer();
       
        printf("Teleporting to Map %d at Position: [%f, %f, %f]\n",
                mapId, posData[0], posData[1], posData[2]);
    }

    // Call the original function if needed
    original_TeleportMap(mapId, position);
}

If needed to create an array, you can pass it to TeleportMap:


C++:
monoArray<float>* CreateFloatArray(int size) {
    monoArray<float>* arr = (monoArray<float>*)malloc(sizeof(monoArray<float>) + sizeof(float) * size);
    arr->max_length = size;
    return arr;
}

// Example usage
monoArray<float>* pos = CreateFloatArray(3);
pos->vector[0] = 100.0f;  // X
pos->vector[1] = 50.0f;   // Y
pos->vector[2] = 200.0f;  // Z

TeleportMap(1, pos); // Call the function
Thanks! Using monoarray worked.
 
Back
Top Bottom