Solvedon/off hotkey problem

Posts 1–5 of 5 · Page 1 of 1
on/off hotkey problem
when i press F1 i want it to toggle a value to 1, then when that key is pressed again i want it to change the value to 0 and so on and so on as much as the user wants to switch between 1 and 0.
God is a boolean with no starting value when it was declaired. ive been trying to figure it out myself for the past 45 minutes or so without luck(my excuse is this is my first time opening visual studio in about a yearish )

Code:
                                 if (GetAsyncKeyState(VK_F1) & 0x0001){
				(ReadProcessMemory(hProcess,(void*)Gadr,&God,sizeof(Points),0));
				if (God = 0){
					God = 1;
				(WriteProcessMemory(hProcess, (LPVOID)Gadr, &God, sizeof(Points), NULL));
				cout << "God Mode ON" <<endl;
				(ReadProcessMemory(hProcess,(void*)Gadr,&God,sizeof(Points),0));
				cout << God <<endl;
				}
				else{
					if (God = 1){
						God = 0;
					(WriteProcessMemory(hProcess, (LPVOID)Gadr, &God, sizeof(Points), NULL));			
				cout << "God Mode OFF" <<endl;
					}
				}
}
Code:
	God = !God;
	
	if (God) {
		// Execute stuff
	}
Quote Originally Posted by InunoTaishou View Post
Code:
	God = !God;
	
	if (God) {
		// Execute stuff
	}
thank you so much
The problems in your code were the comparisons:
Code:
if (God = 1)
is compleatly wrong

Code:
if (God == 1)
Thats how you compare.
@gogogokitty I would recommend you to relearn comparison operators.
Posts 1–5 of 5 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Talk with us