#include <iostream>
#include <Windows.h>
using namespace std;

int main()
{
DWORD pid;
DWORD playerHealth = 0x1DFE9F5B680;
int value = 0;

HWND hwnd = FindWindowA(0, "Grand Theft Auto V");
if (hwnd == NULL)
{
cout << "Cannot find window" << endl;
}

GetWindowThreadProcessId(hwnd, &pid);
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);

if (GetAsyncKeyState(VK_SPACE))
{
WriteProcessMemory(hwnd, (LPVOID)playerHealth, &value, sizeof(value), 0);
}

}


this is a little external hack in c++ i made.
the address in question works when i change it through cheat engine, but when i compile the code and press space, it doesn't work.
this is a console application.
the address is a dynamic address ,but i have not closed the game yet and it works through cheat engine, so it should work here too.