return bool and float

Posts 1–2 of 2 · Page 1 of 1
return bool and float
Code:
bool GetPlayerSpeed(HANDLE hProc, float PlayerSpeed)
{
	if (ReadProcessMemory(hProc, (LPCVOID)SpeedAddress, &PlayerGravity, sizeof(PlayerGravity), NULL))
	{
		return true;
	}
	return false;
}
How do return GetPlayerSpeed bool and PlayerSpeed.

Like that:

Code:
				if (GetPlayerSpeed(hProc, PlayerSpeed))
				{
					cout << s << " = " << PlayerSpeed << endl;
				}
				else cout << "RPM returned false!" << endl;
You can only return a single datatype.
However, you can return a structure which contains multiple fields. Or you can pass a pointer as an argument.
I believe you're trying to use ReadProcessMemory to get the speed correct?

I don't really understand your question because you're passing float playerSpeed as an argument but not doing anything with it.
Then in your second code example you're calling GetPlayerGravity, not GetPlayerSpeed.

ReadProcessMemory you're passing &PlayerGravity, but where is PlayerGravity, is that a global variable?

But I'll assume this is what you're trying to do.
Code:
bool GetPlayerSpeed(HANDLE hProc, float* PlayerSpeed)
{
	if (ReadProcessMemory(hProc, (LPCVOID)SpeedAddress, PlayerSpeed, sizeof(float), NULL))
	{
		return true;
	}
	return false;
}
Code:
float PlayerSpeed = 0;
if (GetPlayerSpeed(hProc, &PlayerSpeed))
				{
					cout << s << " = " << PlayerSpeed << endl;
				}
				else cout << "RPM returned false!" << endl;
Posts 1–2 of 2 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?