Help! How to Make AddMoney Button without Spend/Consume instance?

CelestineMapu

Awesome Active Platinian
Hi Guys, i need your help, i want to make a button that when i click on that button the money will increase, how to make the hook code?

Before, i had a hook but it needs a Conusme/Spend instance, so when i spent the money it will increase, but i want to make it simple by click the button and the AddMoney will called then the money increase

Thanks for helping!

// Hook example that needs cosume/spend instance
void (*AddMoney)(void *instance, int value);
bool (*_ConsumesMoney)(void *instance, int value);
bool ConsumesMoney(void *instance, int value) {
if (instance != NULL) {
AddMoney(instance, 1234);
}
return _ConsumesMoney(instance, value);
}



DobbyHook((void *)getAbsoluteAddress("libil2cpp.so", 0x19B0324), (void *) ConsumesMoney, (void **) &_ConsumesMoney);
AddMoney = (void(*)(void *, int))getAbsoluteAddress(targetLibName, 0x19B0110);
 
you don't need to hook it if that case, when the button is clicked, do FindObjectByType to search the related instance and invoke AddMoney()

you can check unity documentations
 
Back
Top Bottom