Why its not working?? [SOLVED]

Scraatch

Well-Known Member
Joined
Jan 14, 2017
Messages
76
Likes
2
Points
38
Location
Germany
#1
I have this code created but have no idea why the numpad1 function to change the health of the player is not working, i tried it on int and float

C++:
#pragma comment(lib, "Open-SAMP-API.lib")

#include <iostream>
#include "SAMP_API.h"

#define WIN32_LEAN_AND_MEAN
#include "Windows.h"
#include "mem.h"

#define SAMP_DLL        "samp.dll"
#define SAMP_CMP        "F8036A004050518D4C24"

using namespace std;

int unlimitammo = 0;

DWORD CPed = 0xB6F5F0;
DWORD ADDR_INFIRUN = 0xB7CEE4;
DWORD ADDR_ALLNITRO = 0x969165;
DWORD ADDR_INFIAMMO = 0x969178;
DWORD ADDR_CURRENT_WEAPON = 0xBAA410;
DWORD ADDR_VEHICLE_PTR = 0xBA18FC;
DWORD OFFSET_PLAYER_HEALTH = 0x540;

//uintptr_t dwSAMP = (uintptr_t)GetModuleHandle(L"GTA:SA:MP");

int HackThread(void)
{
    do {
        if (GetAsyncKeyState(VK_NUMPAD1))
        {
            *(float*)(0xB6F5F0 + 0x540) = 50;
            *(int*)(0xB6F5F0 + 0x540) = 50;
            AddChatMessage("Health changed");
            cout << "[FUNC] Health changed" << endl;
            Sleep(100);
        }
        if (GetAsyncKeyState(VK_NUMPAD8))
        {
            unlimitammo = !unlimitammo;
            if (unlimitammo) {
                *(int*)(ADDR_INFIAMMO) = 1;
                cout << "[FUNC] Infinity ammunation activated" << endl;
            }
            else {
                *(int*)(ADDR_INFIAMMO) = 0;
                cout << "[FUNC] Infinity ammunation deactivated" << endl;
            }
            char buf[256];
            sprintf_s(buf, "unlimited ammo %s", unlimitammo ? "{FF00FF}activated" : "{00FFFF}deactivated");
            AddChatMessage(buf);
            Sleep(100);
        }
        Sleep(10);
    } while (!GetAsyncKeyState(VK_DELETE));
    ShowGameText("~r~Cheat disabled", 3000, 3);
    return 0;
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
        DisableThreadLibraryCalls(hModule);
        CreateThread(0, 0, (LPTHREAD_START_ROUTINE)HackThread, NULL, 0, 0);
        AllocConsole();
        FILE* fp;
        freopen_s(&fp, "CONOUT$", "w", stdout);
        cout << "SA:MP 0.3.7 Cheat by Ashkan\n\n    DEBUG MODE\n_______________________\nPress DELETE to unload the cheat!\n\n\a";
        break;

    case DLL_PROCESS_DETACH:
        break;
    }
    return true;
}
 
OP
OP
Scraatch

Scraatch

Well-Known Member
Joined
Jan 14, 2017
Messages
76
Likes
2
Points
38
Location
Germany
#5

0x32789

Well-Known Member
Joined
May 26, 2014
Messages
854
Likes
39
Points
78
Location
LongForgotten <-> 0x32789
#6
make a struct
Code:
CPed +0x14
struct stPosition
{
	DWORD rot;
	DWORD x;
	DWORD y;
	DWORD z;
};

read CPed + 0x14 as stPosition

DWORD addr_struct = *(DWORD*)(CPed);
addr_struct = *(DWORD*)(addr_struct + 0x14);

stPosition *stPos = (stPosition*)addr_struct;
stPos->x, stPos->y, stPos->z
idk.. youget the idea
 
Top