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

Help! ERROR TOGGLE

power2020202020

Solid & Active Platinian
Hello, I have a problem with my toggle activator. My hooking works fine in the game, but the activator is always on, even when I turn it off in my mod menu. The damage always stays at 9999999. In fact, it already starts with the damage set to 9999999, even with the toggle turned off. I'll post my mod menu.

bool damageonehit = false;

int (*old_damage)(void *instance);
int damage(void *instance) {
if(instance != NULL && damageonehit)
{
return 9999999;
}
return old_damage(instance);
}



MSHookFunction((void *)getAbsoluteAddress("libil2cpp.so", 0x17C52E8), (void *) damage, (void **) &old_damage);



OBFUSCATE("10_Toggle_damage one hit") //case 10


switch (featNum) {
case 10:
damageonehit = !damageonehit;
break;
}
}
 
Hmm Try

bool damageonehit = false;

int (*old_damage)(void*);
int damage(void *dmg) {
if(dmg != NULL)
{
if(damageonehit)
{
return 9999999;
}
else
{
return 10;//I standards value
}
return old_damage(dmg);
}

Ohh I'm show really the best code ahahhaha

int dmgTest = 50;
int (*old_damage)(void*);
int Damage(void*dmg)
{
if(dmg != NULL)
{
if(damageonehit)
{
dmgTest = old_damage(dmg);
dmgTest = 999999;
}
}
old_damage(dmg);
}
 
No, he's right. It's
case 10:
damageonehit = boolean;
break;
for toggle.

Also works for "ButtonOnOff" but not for "Button".

damageonehit = !damageonehit This works for Button
I don't understand how bool = !bool can work as a button?
Sorry, but only if you have a crookedly written code in Java calling actions, because always if you want to make a switch, then you use bool = !bool, and if just a one-time call then bool = value;
 
I don't understand how bool = !bool can work as a button?
When the button is pressed, code inside the case gets run.
This is just how the mod menu works.
because always if you want to make a switch, then you use bool = !bool, and if just a one-time call then bool = value;
Yeah that's how it would go ideally. I ran into the same problem when I wanted a bool which is true only when the button is pressed.
It's dumb that value = boolean doesn't work in buttons, only in toggles. But that's just how it is :/
 
Review Java Source, maybe the "{" is crooked somewhere or the switch is not specified correctly, because in your .cpp everything is fine