Context: I'm trying to make a few modifications for a game called Grand Theft Auto V.
I'm using GET_ENTITY_COORDS
function to get the coordinates of a entity in the game:
static Inline struct Vector3 GET_ENTITY_COORDS(Entity entity, BOOL alive) {
args[0] = entity;
args[1] = alive;
invokeNative(0x3FEF770D40960D5A);
struct Vector3 vector3 = { *(float*)&rets[0], *(float*)&rets[1], *(float*)&rets[2] };
return vector3;
}
This should return xPos
, yPos
and zPos
.
Now this is the code what I currently are struggling with:
#include "gta.h"
void invokeNative_s(u64 hash) {
struct Native_s** g_Natives = (struct Native_s**)NativeTableAddress;
struct Native_s* Natives = g_Natives[hash & 0xFF];
while (Natives != 0) {
for (unsigned int i = 0; i < Natives->NativeCount; i++) {
if (Natives->NativeHashes[i] == hash) {
((void(*)(struct NativeArg_s*))Natives->NativeFunctions[i])((struct NativeArg_s*)FreeSpaceAddress);
return;
}
}
Natives = Natives->LastNativeTable;
}
}
struct gtaVars_s {
BOOL init;
int frameCount;
};
static struct gtaVars_s *gtaVars = (struct gtaVars_s*)FreeSpaceAddress+0x100;
BOOL nativeHook() {
if (!gtaVars->init) {
nativeArg->ArgValues = args;
nativeArg->ReturnValue = rets;
gtaVars->frameCount = 0;
gtaVars->init = TRUE;
}
int newFrameCount = GET_FRAME_COUNT();
if (gtaVars->frameCount < newFrameCount) {
gtaVars->frameCount = newFrameCount;
Ped pedID = PLAYER_PED_ID();
Player playerID = PLAYER_ID();
/* define player coords */
Vector3 playerCoords = GET_ENTITY_COORDS(pedID, 1);
char waterRadius = 10;
SET_SUPER_JUMP_THIS_FRAME(playerID);
SET_PLAYER_INVINCIBLE(playerID, TRUE);
if (IS_CONTROL_JUST_PRESSED(0, Button_Tpad)) {
// teleport to beach
SET_ENTITY_COORDS(pedID, -1374.881, -1398.835, 6.141, FALSE, FALSE, FALSE, TRUE);
// set water
MODIFY_WATER(playerCoords.x, playerCoords.y, waterRadius, 10);
MODIFY_WATER(playerCoords.x+2, playerCoords.y, waterRadius, 10);
MODIFY_WATER(playerCoords.x, playerCoords.y+2, waterRadius, 10);
MODIFY_WATER(playerCoords.x+2, playerCoords.y+2, waterRadius, 10);
MODIFY_WATER(playerCoords.x+4, playerCoords.y, waterRadius, 10);
MODIFY_WATER(playerCoords.x, playerCoords.y+4, waterRadius, 10);
MODIFY_WATER(playerCoords.x+4, playerCoords.y+4, waterRadius, 10);
MODIFY_WATER(playerCoords.x+6, playerCoords.y, waterRadius, 10);
MODIFY_WATER(playerCoords.x, playerCoords.y+6, waterRadius, 10);
MODIFY_WATER(playerCoords.x+6, playerCoords.y+6, waterRadius, 10);
MODIFY_WATER(playerCoords.x+8, playerCoords.y, waterRadius, 10);
MODIFY_WATER(playerCoords.x, playerCoords.y+8, waterRadius, 10);
MODIFY_WATER(playerCoords.x+8, playerCoords.y+8, waterRadius, 10);
}
}
return TRUE;
}
But I'm getting multiple errors from the GET_ENTITY_COORDS
function even though I have defined the function above in my script:
source/gta.c:42:3: error: unknown type name ‘Vector3’
Vector3 playerCoords = GET_ENTITY_COORDS(pedID, 1);
^
source/gta.c:42:26: error: incompatible types when initializing type ‘int’ using type ‘struct Vector3’
Vector3 playerCoords = GET_ENTITY_COORDS(pedID, 1);
^
source/gta.c:53:29: error: request for member ‘x’ in something not a structure or union
Does anybody know what the cause of this error is, and how I can fix it? I would appreciate it a lot since I'm struggling with this for quite some days and would love to see it resolved, thank you in advance.