Hey guys, I'm having trouble with a bit of code that I wrote, with some help with tutorials and some copy pasta, and for some reason it wont work.
Anyway checkout the code and any help would be great! Thanks for helping a noob out! (:
Main.cpp
Code:
#include "stdafx.h"
#include <iostream>
ProcMem Mem;
using namespace std;
void Trigger();
DWORD ClientDLL;
DWORD LocalPlayer;
DWORD LocalTeam;
DWORD CrossHairID;
DWORD EnemyInCH = NULL;
int EnemyHealth = NULL;
int EnemyTeam = NULL;
int main() {
Mem.Process("csgo.exe");
ClientDLL = Mem.Module("client.dll");
//Player
LocalPlayer = Mem.Read<DWORD>(ClientDLL + PlayerBase);
//Players Team
LocalTeam = Mem.Read<int>(LocalPlayer + TeamOffset);
//Players Cross hair ID
CrossHairID = Mem.Read<int>(LocalPlayer + CrosshairOffset);
while (true){
Trigger();
}
system("pause");
return 0;
}
void Trigger() {
EnemyInCH = Mem.Read<DWORD>(ClientDLL + EntityBase + ((CrossHairID - 1) * EntLoopDist)); // CH = Crosshair.
EnemyHealth = Mem.Read<int>(EnemyInCH + HealthOffset); // Enemy in crosshair's
EnemyTeam = Mem.Read<int>(EnemyInCH + TeamOffset); // Enemy in crosshair's team, we need this to compare it to our own player's team)
if (LocalTeam != EnemyTeam && EnemyHealth > 0 ) {
// Here you can add a delay before shooting, to make it look legit. This is done using Sleep()
mouse_event(MOUSEEVENTF_LEFTDOWN, NULL, NULL, NULL, NULL);
// use Sleep() here for shooting several shots with an ak for example. Not usable with pisto
mouse_event(MOUSEEVENTF_LEFTUP, NULL, NULL, NULL, NULL);
// use Sleep() here for a 'cooldown' between shots.
}
}
stdafx.h
Code:
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
#include <d3d9.h>
#include <d3dx9.h>
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")
#include <dwmapi.h>
#pragma comment(lib, "dwmapi.lib")
#include <string>
#include <TlHelp32.h>
#include <random>
#include <sstream>
#include <fstream>
#include <io.h>
#include <iostream>
#include <algorithm>
#include <future>
#include "D3D.h"
#include "Offsets.h"
#include "ProcMem.h"
Offsets.h
Code:
#pragma once
// Needs to be updated when counter strike is updated.
const DWORD PlayerBase = 0xA6D444;
const DWORD EntityBase = 0x4A5B8F4;
const DWORD CrosshairOffset = 0x0000C554;
// Does not change on updated, in other words, no need to update these!
const DWORD TeamOffset = 0xF0;
const DWORD HealthOffset = 0xFC;
const DWORD EntLoopDist = 0x10;
And the procmem .h & .cpp.