This is the AMP version of this page.
If you want to load the real page instead, click this text.

Help! 2 Fields with same update code doesn't work in my mod menu

Chester Codm

Platinian
void (*old_gravity)(void *instance);
void gravity(void *instance) {
if (instance != NULL) {
if (Gravity) {
*(float *) ((uint32_t) instance + 0x30) = 0;
}
}
return old_gravity(instance);
}

void (*old_fly)(void *instance);
void fly(void *instance) {
if (instance != NULL) {
if (Fly) {
*(float *) ((uint32_t) instance + 0x40) = 0.5;
}
}
return old_fly(instance);
}

HOOK_LIB("libil2cpp.so", "0xA64C08", gravity, old_gravity);
HOOK_LIB("libil2cpp.so", "0xA64C08", fly, old_fly);

What's wrong for only one to work? (I'm a beginner)
 
void(*old_GameManager)(void *instance);
void GameManager(void *instance) {
if(instance != NULL) {
if (isReloading) {
*(float *) ((uint32_t) instance + 0x30) = 0.0f;
}

if (Ammo) { //if Toggle
*(int *) ((uint32_t) instance + 0x32) = 99999;
}

if (UnlockPremium) { //if Toggle
*(bool *) ((uint32_t) instance + 0x343) = true;
}


}
old_GameManager(instance);
}


U gotta use them in one hook

HOOK_LIB("libil2cpp.so", "0x00000", GameManager, old_GameManager);
 



Please, when writing long code snippets, use the Insert Code option.



It's also recommended to use proper indentation for readability purposes.
 
C++:
void (*old_PlayerClass)(void *instance);
void PlayerClass(void *instance) {
if (instance != NULL) {
if (Gravity) {
    *(float *) ((uint32_t) instance + 0x30) = 0.00f;
}
if (fly) {
    *(float *) ((uint32_t) instance + 0x40) = 0.00f;
}
}
return old_PlayerClass(instance);
}
 
One address cannot be hooked twice, and indeed ... For example, one variable field cannot be divided into two during the game and work differently.

Thanks!
 
Void can return value replace return old_PlayerClass(instance) just de return