how do i make yes = a certain value?

Posts 1–12 of 12 · Page 1 of 1
how do i make yes = a certain value?
alright ive gotten myself confused here. for instance the value for god mode in cheat engine says 1050625 for on, and 105624 for off. in my trainer how would i make it so you can type ON for god mode and Off for godmode to be turned off. ive tried (int on = 1050625 but when you type yes into the consol it just forms a infinite loop and keeps typing the same thing on screen
heres what it looks like when i type in 1050625 to turn god mode on

and heres what it looks like when i type in yes

i made the int yes = 105625 in green

Code:
int main()
{	
	string response;

	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 10);
	cout << "		     gogogokitty199's   GOD      MODE\n";
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 14);
	cout << "\n";
	cout << "\n";
	cout << "Make sure World at War is opened before continuing.\n";
	system("Pause");
	LPCWSTR Waw = L"Call of Duty®";
	HWND hwnd = FindWindow(0, Waw);
	if (hwnd == 0)
	{
		system("color c2");
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 3);
		cout << "ERROR WORLD AT WAR HAS NOT BEEN FOUND!!!I told you to make sure its open!!!";
		cin.get();
		exit(1);
	}
	else
	{
		DWORD process_ID;
		GetWindowThreadProcessId(hwnd, &process_ID);
		HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, process_ID);
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 3);

		//program resets here
		while (true)
		{
			cout << "God Mode off = 105624	God Mode on = 1050625: ";
			int yes = 1050625;
			int Points;
			cin >> Points;
			DWORD newdatasize = sizeof(Points);
			if (WriteProcessMemory(hProcess, (LPVOID)0x0176C8A4, &Points, newdatasize, NULL))
				cout << "memory has been changed \n";
			cout << " \n";

		}
	}


}
So, if I've understood this right you just wanna type ON to turn on godmode and OFF to turn off godmode.
If thats the case it should look something like this.
Code:
#include <string>
int main(){
	string name;
	cin >> name;

	if(name == "ON"){
		//Whatever you wanna do
	}

	if(name == "OFF"){
		//Whatever you wanna do
	}
}
Quote Originally Posted by KoFar View Post
So, if I've understood this right you just wanna type ON to turn on godmode and OFF to turn off godmode.
If thats the case it should look something like this.
Code:
#include <string>
int main(){
	string name;
	cin >> name;

	if(name == "ON"){
		//Whatever you wanna do
	}

	if(name == "OFF"){
		//Whatever you wanna do
	}
}
Yea I think that's what his looking for.
Quote Originally Posted by KoFar View Post
So, if I've understood this right you just wanna type ON to turn on godmode and OFF to turn off godmode.
If thats the case it should look something like this.
Code:
#include <string>
int main(){
	string name;
	cin >> name;

	if(name == "ON"){
		//Whatever you wanna do
	}

	if(name == "OFF"){
		//Whatever you wanna do
	}
}
thanks for the reply. im still having a issue and i cant figure out what im doing wrong, im making a dumb mistake somewhere
Code:
{
			cout << "type, OFF, ON: ";
			string name;
			cin >> name;
			if (name == "ON"){
				name = 1050625;
				DWORD newdatasize = sizeof(name);
				(WriteProcessMemory(hProcess, (LPVOID)0x0176C8A4, &name, newdatasize, NULL));
					cout << "memory has been changed \n";
				cout << " \n";
			}

		}
Quote Originally Posted by gogogokitty View Post
thanks for the reply. im still having a issue and i cant figure out what im doing wrong, im making a dumb mistake somewhere
Code:
{
			cout << "type, OFF, ON: ";
			string name;

			cin >> name;
			if (name == "ON"){
				name = 1050625;
				DWORD newdatasize = sizeof(name);
				(WriteProcessMemory(hProcess, (LPVOID)0x0176C8A4, &name, newdatasize, NULL));
					cout << "memory has been changed \n";
				cout << " \n";
			}

		}
Name is a string, meaning it can only hold Characters and not numbers.
Also you don't have to name your string "Name" you can name it anything you like.

So something like this should do it.
Code:
cout << "type, OFF, ON: ";
			string name;
                        int value;
			cin >> name;
			if (name == "ON"){
				value = 1050625;
				DWORD newdatasize = sizeof(value);
				(WriteProcessMemory(hProcess, (LPVOID)0x0176C8A4, &value, newdatasize, NULL));
					cout << "memory has been changed \n";
				cout << " \n";
			}
Quote Originally Posted by gogogokitty View Post
thanks for the reply. im still having a issue and i cant figure out what im doing wrong, im making a dumb mistake somewhere
Code:
{
			cout << "type, OFF, ON: ";
			string name;
			cin >> name;
			if (name == "ON"){
				name = 1050625;
				DWORD newdatasize = sizeof(name);
				(WriteProcessMemory(hProcess, (LPVOID)0x0176C8A4, &name, newdatasize, NULL));
					cout << "memory has been changed \n";
				cout << " \n";
			}

		}
To be honest I would recommend you to use GetAsyncKeyState instead of this, much easier to just press f1 and then the godmode is on
Quote Originally Posted by KoFar View Post
Name is a string, meaning it can only hold Characters and not numbers.
Also you don't have to name your string "Name" you can name it anything you like.

So something like this should do it.
Code:
cout << "type, OFF, ON: ";
			string name;
                        int value;
			cin >> name;
			if (name == "ON"){
				value = 1050625;
				DWORD newdatasize = sizeof(value);
				(WriteProcessMemory(hProcess, (LPVOID)0x0176C8A4, &value, newdatasize, NULL));
					cout << "memory has been changed \n";
				cout << " \n";
			}
thank you that worked, and it helped me understand what i was doing wrong
what type of issue? ...it's even harder for us to "guess" what's going on : p

Compile-time error (ie. code is in invalid format/syntax) or run-time (exception/crash, or simply not doing what you expect) ??

If one of the sourcecode lines has a red squiggly-line under it, that's a syntax (compile-time) error. Please tell us which line it's on. A screenshot is worth a thousand words. Also please show which #includes <> you have..as it could be related to the 'string' error.

Working code
Code:
#include <iostream>
#include <string>
#include <Windows.h>

using namespace std;


int main(int argc, const char * argv[])
{
string userInput;
cout <<"GODMODE: ON or OFF?\n";
cout <<"Input: ";
cin >> userInput;

if (userInput == "ON" || userInput == "on" || userInput == "On")
{
	MessageBoxA(0,"Success: ON","ON",0);
}
else if (userInput == "OFF" || userInput == "off" || userInput == "Off")
{
	MessageBoxA(0,"Success: OFF","OFF",0);
}
else
{
	MessageBoxA(0,"Invalid Input","ERROR",0);
}

	system("PAUSE");
    return 0;
}




edit: @KoFar

"Name is a string, meaning it can only hold Characters and not numbers."
Huh? 0-9 have character representations... ? And OP is trying to get string input anyway, so I'm not sure why you brought that up. I'm not sure what you mean / what you were trying to tell OP.
Also, if OP having trouble with if{}, cin, and strings, I expect trying to use GetAsyncKeyState would only add complexity for him. Valid suggestion, but probably doesn't help OP much.
"Name is a string, meaning it can only hold Characters and not numbers."
Huh? 0-9 have character representations... ? And OP is trying to get string input anyway, so I'm not sure why you brought that up. I'm not sure what you mean / what you were trying to tell OP.
Also, if OP having trouble with if{}, cin, and strings, I expect trying to use GetAsyncKeyState would only add complexity for him. Valid suggestion, but probably doesn't help OP much.[/QUOTE]

it helps a little. im experimenting with GetAsyncKeyState but im having a issue getting it to stop spamming my messages
Code:
while (true)
		{

			{ cout << "press F3 to turn GOD MODE on\n";

			{int value;
			if (GetAsyncKeyState(VK_F3)){
				value = 1050625;
				DWORD newdatasize = sizeof(value);
				(WriteProcessMemory(hProcess, (LPVOID)0x0176C8A4, &value, newdatasize, NULL));
				cout << "memory has been changed \n";
				cout << " \n";
			}
			}
			}

			{
			int value;
			if (GetAsyncKeyState(VK_F4)){
				value = 105624;
				DWORD newdatasize = sizeof(value);
				(WriteProcessMemory(hProcess, (LPVOID)0x0176C8A4, &value, newdatasize, NULL));
				cout << "memory has been changed \n";
				cout << " \n";
			}
		}

		}
i put a system("pause"); at the end of the while bracket and it works now, but i have to alt tab when i press F3 or F4 for it to do anything in the consol and the game

heres when i run the program

heres when i tap F3 and pressed the print screen key right after
look at your code

while (true) // an infinite loop

cout << a message; // call cout

GetAsyncKey...() ; // check for key-press


while(true) is a loop that will (can) run indefinitely -- as fast as it can. And since the only other thing you're doing is calling cout<< and cheking for a keypress..it does that very quickly, and then does it again, and continues. nothing to make it do otherwise.

I'm not sure what you're going for exactly (personally, I'd switch back to taking a user input string as mentioned above..), but here is another example:

Code:
int value = 0; 
cout << "press F3 to turn GOD MODE on, F4 to turn OFF" << endl;

while (true)
{

			if (GetAsyncKeyState(VK_F3))
                        {
				value = 1050625;
                                // ...
                                cout <<"God Mode ENABLED" << endl;
			}

			else if (GetAsyncKeyState(VK_F4))
                        {
                                value = 1050624;
	                        // ...
                                cout <<"God Mode DISABLED" << endl;
			}
                        Sleep(1000); // else this code might run multiple times per 1 key strike.
} // you should probably add a way to close the program (leave the loop). TODO:
Note about GetAsyncKeyState()'s return value:
"If the most significant bit is set, the key is down, and if the least significant bit is set, the key was pressed after the previous call to GetAsyncKeyState." http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx
@abuckau907 well, GetAsyncKeyState() is something I just think is easier to use and thats why i recommended it.
And for string I guess explained it wrong, sorry. What I actually meant was that a string is only used for display, meaning it can't hold a value so for example you can't set an int's value to a strings since the string doesn't hold any values capable for an int, meaning that you can't do a WPM function with a string to give yourself godmode, but you can change your name and other kind of strings.

Hope that explanation was better.

@gogogokitty If you want to stop the spam with GetAsyncKeyState() just add &1 to it, example:
Code:
if(GetAsyncKeyState(VK_F3) &1
Or you can make it sleep for some secs, example.
Code:
if(GetAsyncKeyState(VK_F3){
//WPM Function
Sleep(500);
}
I recommend you to use the first one tho, it's easier and less buggy.

And the spam in the beggining is because you're using while(true), an infinite loop as abuckau said earlier, just put a Sleep() in the end of function and it wont spam as much.
Quote Originally Posted by KoFar View Post
@abuckau907 well, GetAsyncKeyState() is something I just think is easier to use and thats why i recommended it.
And for string I guess explained it wrong, sorry. What I actually meant was that a string is only used for display, meaning it can't hold a value so for example you can't set an int's value to a strings since the string doesn't hold any values capable for an int, meaning that you can't do a WPM function with a string to give yourself godmode, but you can change your name and other kind of strings.

Hope that explanation was better.

@gogogokitty If you want to stop the spam with GetAsyncKeyState() just add &1 to it, example:
Code:
if(GetAsyncKeyState(VK_F3) &1
Or you can make it sleep for some secs, example.
Code:
if(GetAsyncKeyState(VK_F3){
//WPM Function
Sleep(500);
}
I recommend you to use the first one tho, it's easier and less buggy.

And the spam in the beggining is because you're using while(true), an infinite loop as abuckau said earlier, just put a Sleep() in the end of function and it wont spam as much.
i got everything fixed now, added & 0x0001 to the end of them and it set it up nicely thanks guys
Posts 1–12 of 12 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us