Closing thread upon cheat's closure and getasynckeystate

Posts 1–10 of 10 · Page 1 of 1
Closing thread upon cheat's closure and getasynckeystate
Problem 1: Whenever i close my cheat the threads are still running, thus it still reads and writes to the memory.
Problem 2: I want to turn cheat features on and off when pressing a Key. It works, but i can only turn them on and not turn them off anymore.

Code:

main.cpp

Code:
void main()

{
	
	Mem.Process("csgo.exe");
	Client = Mem.Module("client.dll");
	
	
	
	thread NoFlash_thread = thread(NoFlash);
	
	

	NoFlash_thread.join();
	
}
	
void NoFlash()
{
	
	
	while (true)
	{
		if (GetAsyncKeyState(VK_F1) & 0x8000){

			flashshow = !flashshow;
		}
		if (flashshow)
		{


		// read and write
		

	}
		Sleep(1);
		
	}
}
std::thread::join is the correct way to make sure your threads aren't running anymore when the executable closes.
If you still have problems, you're doing something wrong.

Your thread is running at a fast iteration rate, which means that once you press the button that triggers the GetAsyncKeyState, you'll likely hold the button for more than one iteration of your thread. This means that the variable you're using to enable or disable the features is getting switched multiple times. To prevent that from happening, add a sleep after flashshow = !flashshow; of about 1000 milliseconds. You're also bitmasking the GetAsyncKeyState result with 0x8000, which is the exact opposite of what you want. You want to know if you pressed the key, not if you're holding the key ( aka pressed since last call ).
I added the sleep and GetAsyncKeyState(VK_F1), but it still doesnt work. What am i doing wrong?
Quote Originally Posted by antep2727 View Post
I added the sleep and GetAsyncKeyState(VK_F1), but it still doesnt work. What am i doing wrong?
Does your cheat not work? Your threading? Your game? Your no flash? You gotta be specific when you say "it doesn't work".

If you're talking about toggleing the no flash feature, i hope you know that the game doesn't rewrite m_flFlashMaxAlpha, which means that you have to rewrite it back to 255 if you want to get flashed again ( if you're using m_flFlashMaxAlpha ).
Quote Originally Posted by WasserEsser View Post
Does your cheat not work? Your threading? Your game? Your no flash? You gotta be specific when you say "it doesn't work".

If you're talking about toggleing the no flash feature, i hope you know that the game doesn't rewrite m_flFlashMaxAlpha, which means that you have to rewrite it back to 255 if you want to get flashed again ( if you're using m_flFlashMaxAlpha ).
That seems to be the problem lol

One more question:

Whenever i leave a game and back to lobby sometimes the game crashes. Could the reason be because i am not checking if i am connected to the game ( ConnectedPlayer == 6) and the cheats tries to write to memory?
But if i am in matchmaking lobby i can play endless game and it will never crash.
Quote Originally Posted by antep2727 View Post
That seems to be the problem lol

One more question:

Whenever i leave a game and back to lobby sometimes the game crashes. Could the reason be because i am not checking if i am connected to the game ( ConnectedPlayer == 6) and the cheats tries to write to memory?
But if i am in matchmaking lobby i can play endless game and it will never crash.
Make sure to check if the local player address is valid by checking it against null.

Code:
if ( LocalPlayer ) // do stuff
Quote Originally Posted by antep2727 View Post
That seems to be the problem lol

One more question:

Whenever i leave a game and back to lobby sometimes the game crashes. Could the reason be because i am not checking if i am connected to the game ( ConnectedPlayer == 6) and the cheats tries to write to memory?
But if i am in matchmaking lobby i can play endless game and it will never crash.

If you think that this is true, which i doubt, you could use this:
Code:
void InGame()
{
	while (true)
	{
		DWORD InGame = engine.InGame(); //engine pointer + ingame offset
		if (InGame == 0)
		{
			Sleep(1000); //
			//cout << "not ingame\n";
			return;
		}

		//cout << "ingame";
		break;
	}
}
this is what i use to check if im ingame...
Quote Originally Posted by gauthier08 View Post
If you think that this is true, which i doubt, you could use this:
Code:
void InGame()
{
	while (true)
	{
		DWORD InGame = engine.InGame(); //engine pointer + ingame offset
		if (InGame == 0)
		{
			Sleep(1000); //
			//cout << "not ingame\n";
			return;
		}

		//cout << "ingame";
		break;
	}
}
this is what i use to check if im ingame...
If you're checking signonstate, you should either be checkig if it's >= SIGNONSTATE_CONNECTED && <= SIGNONSTATE_FULL or check if it's equal to SIGNONSTATE_FULL.

https://github.com/LestaD/SourceEngi...rotocol.h#L159ⓘ
This can be closed, solved all my (current xd) problems.

Thanks everyone for helping ^^
/Solved & closed.
Posts 1–10 of 10 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us