Help! Original value on slide..

MasterCodeView

Solid & Active Platinian
Original poster
Nov 23, 2020
50
7
8
24
Brasil
float = 5;

float (*old_speed)(void *instance);
float speed(void *instance) {
if (instance != NULL && Speed) {
return (float) Speed;
}
return old_speed(instance);
}
HOOK_LIB("libil2cpp.so", "0x46DD9C", speed, old_speed);

OBFUSCATE("10_CollapseAdd_SeekBar_SPEED_1_50"),

case 10:
Speed = value;
break;

Does anyone know if it's possible to make the value go back to the original when the slide is between 1 and 5?
 

DigitalKnight

Approved Modder
Approved Modder
Jul 31, 2018
185
11,121
1,193
23
Within the Heart
You can make a reset button i guess. You would have to pass a pointer to the slider value in the button case and set the value back to original
 

DigitalKnight

Approved Modder
Approved Modder
Jul 31, 2018
185
11,121
1,193
23
Within the Heart
Code:
int *valueptr;
int slidervalue = 1;

// Rest of Code

case 0: //Your slider Case
 if(valueptr == NULL){
    valueptr = &value;
   }
   slidervalue = value;
   break;
case 1: //Your reset button case
   if(valueptr != NULL){
       *valueptr = 1;
     }
     break;
Try this
 

MasterCodeView

Solid & Active Platinian
Original poster
Nov 23, 2020
50
7
8
24
Brasil
Code:
int *valueptr;
int slidervalue = 1;

// Rest of Code

case 0: //Your slider Case
 if(valueptr == NULL){
    valueptr = &value;
   }
   slidervalue = value;
   break;
case 1: //Your reset button case
   if(valueptr != NULL){
       *valueptr = 1;
     }
     break;
Try this
Did not work :(
 

DigitalKnight

Approved Modder
Approved Modder
Jul 31, 2018
185
11,121
1,193
23
Within the Heart
It will set the slider value back to original, but it might not change the visual slider value on mod menu. For that you might have to update/sync the display. I am not sure how to do that but maybe someone can help
 

DigitalKnight

Approved Modder
Approved Modder
Jul 31, 2018
185
11,121
1,193
23
Within the Heart
Not quite how to explain it but... But there is a way when the slide is between 1 and 5 it goes back to the original value (I don't know what the original value is in libil2cpp so I can put it in the mod)
If you want the original code restored, you can disable your hook and use RESTORE_LIB() (The examples are there in the menu template). Not sure if i am still getting your question properly
 

Raebydett

Awesome Active Platinian
Jan 20, 2020
171
60
28
G
Not quite how to explain it but... But there is a way when the slide is between 1 and 5 it goes back to the original value (I don't know what the original value is in libil2cpp so I can put it in the mod)
Im gonna put u on simple way to understand

C++:
float(*old_Speed)(void *instance);
float Speed(void *instance) {
    if (instance != NULL && speed > 1) {
        return old_Speed(instance) * (float)speed; //original value * (your value)
    }
    return old_Speed(instance);
}
 

MasterCodeView

Solid & Active Platinian
Original poster
Nov 23, 2020
50
7
8
24
Brasil
If you want the original code restored, you can disable your hook and use RESTORE_LIB() (The examples are there in the menu template). Not sure if i am still getting your question properly
not quite that, for example when the slide is between 0~5 it will be the original value, but when it is in the other number it will increase according to the number, but thanks anyway.
 

MasterCodeView

Solid & Active Platinian
Original poster
Nov 23, 2020
50
7
8
24
Brasil
If you want the original code restored, you can disable your hook and use RESTORE_LIB() (The examples are there in the menu template). Not sure if i am still getting your question properly
Guess what I want is not possible, thanks and sorry for taking your time
 

MasterCodeView

Solid & Active Platinian
Original poster
Nov 23, 2020
50
7
8
24
Brasil
Im gonna put u on simple way to understand

C++:
float(*old_Speed)(void *instance);
float Speed(void *instance) {
    if (instance != NULL && speed > 1) {
        return old_Speed(instance) * (float)speed; //original value * (your value)
    }
    return old_Speed(instance);
}
It worked, but I don't know the original code value in the lib.
 

Raebydett

Awesome Active Platinian
Jan 20, 2020
171
60
28
G
Well some class do show original value in field, not always. The other option is do debug logs whatever value pass in that func