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

Help! Help with adding coins

A.Flores

Platinian
Hi everyone. In dump.cs, I found this method:
Code:
// RVA: 0x16657f8 VA: 0x77a6ad07f8
 public Void AddCoins(Int32 amount, CoinsEarnedMethod earnedMthod, Boolean storeBackup) { }
I tried to hook it using different methods to call it, and it works; coins are added under certain conditions.

But I'm interested in whether it's possible to call such methods in the LGL menu when a switch is pressed in the running game. That is, I want the balance to be increased by, for example, 5000 coins when the button is pressed
 
How did you hook?

Something like this:
Code:
void (*AddCoins)(void *instance, int amount, int earnedMthod, bool storeBackup);
bool (*_SpendCoins)(void *instance, int amount);
bool SpendCoins(void *instance, int amount) {
    if(instance != NULL) {
    
    AddCoins(instance, 5000, 1, true);
    
    }
    return _SpendCoins(instance, amount);
}

DobbyHook((void *)getAbsoluteAddress("libil2cpp.so", 0x1668ec4), (void *) SpendCoins, (void **) &_SpendCoins);
AddCoins = (void(*)(void *, int, int, bool))getAbsoluteAddress(targetLibName, 0x16657f8);

/*dump.cs:
 // RVA: 0x16657f8 VA: 0x77a6ad07f8
 public Void AddCoins(Int32 amount, CoinsEarnedMethod earnedMthod, Boolean storeBackup) { }
 // RVA: 0x1668ec4 VA: 0x77a6ad3ec4
 public Boolean SpendCoins(Int32 amount) { }
*/
 
You can configure a button in LGL menu to call the function when pressed, yes.
If you already have the menu set up, you'll just have to add a button into the features array, like: OBFUSCATE("1_Button_Add Coins"). Then in the switches section you can put the function AddCoins(instance, 5000, 1, true); in the switch 1 so that it gets called when the button is pressed..
 
Oh and you'll need to hook the addcoins function. No need for the other bool also

Can I have an example code?
 
Let me clarify exactly what I need, as I think I might not have conveyed my thoughts well, or the translator might not have been entirely accurate.

I launch the game and see my coin balance, which is 40,000, for example. I want to activate a toggle button so that my balance increases by 5,000 coins, making the balance 45,000. Then I activate the button again, and the balance becomes 50,000, and so on.
 
This does exactly that. Makes a button which gives you coins when pressed.
 
[Hidden content]
Thank you, of course, but there is a similar example in main.cpp in the lgl project. I wrote this hook with SpendCoins just to check if addcoins works, which it does when I spend coins. SpendCoins can be replaced with Start, for example, and then 5000 coins will be added each time the application starts. Your code does not implement coin increase when the button is pressed; it only activates/deactivates the coin increase when they are spent