Solved How to Return Original Value of a Method Bound with Update Function.

Status
Not open for further replies.

AmateurHacker

Platinian
I'm using the code below to change the camera angle, and it works fine. The original Field of View Float value is 30.0. I change it to 12.0, and it works. But when I close the tool, I want the value to return to its original value. In short, when the tool is open, it returns a float of 12.0. When the tool is closed, it should return a float of 30.0. In other words, it should return its original value.


1754411254280.png

It should get the original value when Toogle is closed.
What should I add to my code for this?











bool FielofViews;

void (*SetCameraFov)(void* instance,float fieldOfView);
void (*old_Update)(void* instance);
void new_Update(void* instance) {
if (instance != nullptr) {
if (FielofViews) {

SetCameraFov (instance,16.0);
}

}

old_Update(instance);
}
 
C++:
bool FielofViews;
void (*SetCameraFov)(void* instance,float fieldOfView);
void (*old_Update)(void* instance);
void new_Update(void* instance) {
    if (instance != nullptr) {
        if (FielofViews) {
            SetCameraFov (instance,16.0);
        } else {
            SetCameraFov (instance,30.0);
        }
    }
    old_Update(instance);
}
 
C++:
bool FielofViews;
void (*SetCameraFov)(void* instance,float fieldOfView);
void (*old_Update)(void* instance);
void new_Update(void* instance) {
    if (instance != nullptr) {
        if (FielofViews) {
            SetCameraFov (instance,16.0);
        } else {
            SetCameraFov (instance,30.0);
        }
    }
    old_Update(instance);
}
I already solved this problem. A new problem has arisen. There are multiple camera instances in setcamerafov. I only want to rotate the second one. Its float value is 30.0f. How can I select it so that it only rotates the second one?
The camera I'm trying to change is always listed second in this section, and its value is 30.0f. Is it possible to change only this camera? How can I access it?





1754558249829.png
 
I already solved this problem. A new problem has arisen. There are multiple camera instances in setcamerafov. I only want to rotate the second one. Its float value is 30.0f. How can I select it so that it only rotates the second one?
The camera I'm trying to change is always listed second in this section, and its value is 30.0f. Is it possible to change only this camera? How can I access it?





View attachment 795271
make a new issue for this, so you can close this one
and you can make a function to first get the original value
and save that value, and dont update it
and when the toggle is off, return the original value. [this works if you have no idea what the value is, or it keeps changing per match / weapon. like ammo for specific gun]
and for the second issue,
so, if the value is always 30, but the rest cameras are 29, 28 .. different values
make unlink function, and make it only changes if the original value was the one with the 30 .
 
This thread will be set to "solved" and the thread will be locked.

If you feel like that the answers you got are not solving your problem or answering your question, please feel free to contact me and I'll re-open this thread for you.
 
Status
Not open for further replies.
Back
Top Bottom