Results 1 to 2 of 2
  1. #1
    toxdope's Avatar
    Join Date
    Sep 2016
    Gender
    male
    Posts
    3
    Reputation
    10
    Thanks
    0

    Lightbulb [AssaultCube] ESP bugging out and only working while looking at one side of the map

    I've been following Fleep's tutorial on making an ESP.

    This is the result. It only works when I look at one side of the world, when I turn around nothing gets drawn.
    It just keeps flickering and drawing in the center and not showing the actual position of enemy players whatsoever.




    Here is the code, mainly the same as Fleep's with some of mine adjustments. I know how viewmatrices and wts function work, I did not just copy his code (except the draw functions). I tried to figure it out on my own for the past 2 days but I dont seem to getting better results.

    Source/main
    Code:
    #include <iostream>
    #include <Windows.h>
    #include <stdio.h>
    #include "lPlayer.h"
    #include "pList.h"
    #include <sstream>
    using namespace std;
    
    //ESP VARIABLES
    RECT m_Rect;
    HDC HDC_Desktop;
    HBRUSH EnemyBrush;
    HFONT Font;
    COLORREF SnaplineColor;
    COLORREF TextColor;
    
    lPlayer localPlayer;
    pList PlayerList[32];
    
    HANDLE hndl;
    HWND hwnd;
    DWORD pID;
    
    //MAIN ADDRESSES
    DWORD dw_EntityBase = 0x510D90;
    DWORD dw_EntityLoopOff = 0x4;
    DWORD dw_viewMatrix = 0x501AE8;
    DWORD dw_Base = 0x50F4E8;
    DWORD dw_LocalPlayer = 0x509B74;
    
    //OFFSETS
    DWORD dw_HealthOff = 0xF8;
    DWORD dw_mouseX = 0x40;
    DWORD dw_mouseY = 0x44;
    DWORD dw_posX = 0x4;
    DWORD dw_posZ = 0x8;
    DWORD dw_posY = 0xC;
    DWORD dw_team = 0x32C;
    DWORD dw_numPlayers = 0x18;
    
    float Get3dDistance(float* myCoords, float* enemyCoords) {
    	return sqrt(
    		pow(double(enemyCoords[0] - myCoords[0]), 2.0) +
    		pow(double(enemyCoords[1] - myCoords[1]), 2.0) +
    		pow(double(enemyCoords[2] - myCoords[2]), 2.0));
    };
    
    void SetupDrawing(HDC hDesktop, HWND handle) {
    	HDC_Desktop = hDesktop;
    	hndl = handle;
    	EnemyBrush = CreateSolidBrush(RGB(255, 0, 0));
    	SnaplineColor = RGB(0, 255, 0);
    	TextColor = RGB(0, 0, 255);
    };
    
    bool WorldToScreen(float* from, float* to)
    {
    	float w = 0.0f;
    
    	to[0] = localPlayer.wts.flMatrix[0][0] * from[0] + localPlayer.wts.flMatrix[0][1] * from[1] + localPlayer.wts.flMatrix[0][2] * from[2] + localPlayer.wts.flMatrix[0][3];
    	to[1] = localPlayer.wts.flMatrix[1][0] * from[0] + localPlayer.wts.flMatrix[1][1] * from[1] + localPlayer.wts.flMatrix[1][2] * from[2] + localPlayer.wts.flMatrix[1][3];
    	w = localPlayer.wts.flMatrix[3][0] * from[0] + localPlayer.wts.flMatrix[3][1] * from[1] + localPlayer.wts.flMatrix[3][2] * from[2] + localPlayer.wts.flMatrix[3][3];
    
    	if (w < 1.0)
    		return false;
    
    	float invw = 1.0f / w;
    	to[0] *= invw;
    	to[1] *= invw;
    
    	int width = (int)(m_Rect.right - m_Rect.left);
    	int height = (int)(m_Rect.bottom - m_Rect.top);
    
    	float x = width / 2;
    	float y = height / 2;
    
    	x += 0.5 * to[0] * width + 0.5;
    	y -= 0.5 * to[1] * height + 0.5;
    
    	to[0] = x + m_Rect.left;
    	to[1] = y + m_Rect.top;
    
    	return true;
    }
    
    void DrawFilledRect(int x, int y, int w, int h)
    {
    	hwnd = FindWindow(0, "AssaultCube");
    	HDC HDC_Desktop = GetDC(hwnd);
    	//We create our rectangle to draw on screen
    	RECT rect = { x, y, x + w, y + h };
    	//We clear that portion of the screen and display our rectangle
    	FillRect(HDC_Desktop, &rect, EnemyBrush);
    }
    
    
    void DrawBorderBox(int x, int y, int w, int h, int thickness)
    {
    	//Top horiz line
    	DrawFilledRect(x, y, w, thickness);
    	//Left vertical line
    	DrawFilledRect(x, y, thickness, h);
    	//right vertical line
    	DrawFilledRect((x + w), y, thickness, h);
    	//bottom horiz line
    	DrawFilledRect(x, y + h, w + thickness, thickness);
    }
    
    
    //Here is where we draw our line from point A to Point B
    void DrawLine(float StartX, float StartY, float EndX, float EndY, COLORREF Pen)
    {
    	hwnd = FindWindow(0, "AssaultCube");
    	HDC HDC_Desktop = GetDC(hwnd);
    	int a, b = 0;
    	HPEN hOPen;
    	// penstyle, width, color
    	HPEN hNPen = CreatePen(PS_SOLID, 2, Pen);
    	hOPen = (HPEN)SelectObject(HDC_Desktop, hNPen);
    	// starting point of line
    	MoveToEx(HDC_Desktop, StartX, StartY, NULL);
    	// ending point of line
    	a = LineTo(HDC_Desktop, EndX, EndY);
    	DeleteObject(SelectObject(HDC_Desktop, hOPen));
    }
    
    //Draw our text with this function
    void DrawString(int x, int y, COLORREF color, const char* text)
    {
    	hwnd = FindWindow(0, "AssaultCube");
    	HDC HDC_Desktop = GetDC(hwnd);
    	SetTextAlign(HDC_Desktop, TA_CENTER | TA_NOUPDATECP);
    
    	SetBkColor(HDC_Desktop, RGB(0, 0, 0));
    	SetBkMode(HDC_Desktop, TRANSPARENT);
    
    	SetTextColor(HDC_Desktop, color);
    
    	SelectObject(HDC_Desktop, Font);
    
    	TextOutA(HDC_Desktop, x, y, text, strlen(text));
    
    	DeleteObject(Font);
    }
    
    
    void DrawESP(int x, int y, float distance)
    {
    	//ESP RECTANGLE
    	int width = 18100 / distance;
    	int height = 36000 / distance;
    	DrawBorderBox(x - (width / 2), y - height, width, height, 1);
    
    	//Sandwich ++
    	DrawLine((m_Rect.right - m_Rect.left) / 2,
    		m_Rect.bottom - m_Rect.top, x, y,
    		SnaplineColor);
    
    
    	std::stringstream ss;
    	ss << (int)distance;
    
    	char* distanceInfo = new char[ss.str().size() + 1];
    	strcpy(distanceInfo, ss.str().c_str());
    
    	DrawString(x, y, TextColor, distanceInfo);
    
    	delete[] distanceInfo;
    }
    
    void ESP()
    {
    	GetWindowRect(FindWindow(NULL, "AssaultCube"), &m_Rect);
    
    	for (int i = 0; i < localPlayer.numPlayers; i++)
    	{
    		PlayerList[i].ReadInformation(i);
    
    		if (PlayerList[i].Health < 2)
    			continue;
    
    		if (PlayerList[i].Team == localPlayer.Team)
    			continue;
    
    		float EnemyXY[3];
    		if (WorldToScreen(PlayerList[i].Position, EnemyXY))
    		{
    			DrawESP(EnemyXY[0] - m_Rect.left, EnemyXY[1] - m_Rect.top, Get3dDistance(localPlayer.Position, PlayerList[i].Position));
    		}
    
    	}
    
    }
    
    int main()
    {
    	hwnd = FindWindow(0, "AssaultCube");
    	GetWindowThreadProcessId(hwnd, &pID);
    
    	hndl = OpenProcess(PROCESS_ALL_ACCESS, false, pID);
    
    	HDC HDC_Desktop = GetDC(hwnd);
    	SetupDrawing(HDC_Desktop, hwnd);
    
    	while (1) {
    		localPlayer.ReadInformation();
    
    		ESP();
    	}
    
    }
    lPlayer.h
    Code:
    #pragma once
    #include <Windows.h>
    
    typedef struct {
    	float flMatrix[4][4];
    }WTS_t;
    
    class lPlayer
    {
    public:
    	int numPlayers;
    	DWORD localPl;
    	int Team;
    	int Health;
    	WTS_t wts;
    	float Position[3];
    	DWORD base;
    
    
    	void ReadInformation() {
    		HWND hwnd = FindWindow(0, "AssaultCube");
    		DWORD pID;
    		GetWindowThreadProcessId(hwnd, &pID);
    
    		HANDLE hndl = OpenProcess(PROCESS_ALL_ACCESS, false, pID);
    
    		ReadProcessMemory(hndl, (LPCVOID)dw_LocalPlayer, &localPl, sizeof(localPl), NULL);
    		ReadProcessMemory(hndl, (LPCVOID)(localPl + dw_team), &Team, sizeof(Team), NULL);
    		ReadProcessMemory(hndl, (LPCVOID)(localPl + dw_HealthOff), &Health, sizeof(Health), NULL);
    		ReadProcessMemory(hndl, (LPCVOID)(localPl + dw_posX), &Position, sizeof(float[3]), NULL);
    
    		ReadProcessMemory(hndl, (LPCVOID)(dw_Base + dw_numPlayers), &numPlayers, sizeof(int), NULL);
    
    		ReadProcessMemory(hndl, (LPCVOID)(dw_viewMatrix), &wts, sizeof(wts), NULL);
    
    	}
    };
    pList.h
    Code:
    #pragma once
    #include <Windows.h>
    class pList
    {
    public:
    	DWORD baseEntity;
    	DWORD baseEntFinal;
    	int Team;
    	int Health;
    	float Position[3];
    	char name[39];
    
    	void ReadInformation(int player) {
    		HWND hwnd = FindWindow(0, "AssaultCube");
    		DWORD pID;
    		GetWindowThreadProcessId(hwnd, &pID);
    
    		HANDLE hndl = OpenProcess(PROCESS_ALL_ACCESS, false, pID);
    
    		ReadProcessMemory(hndl, (LPCVOID)(dw_EntityBase), &baseEntity, sizeof(DWORD), NULL);
    		ReadProcessMemory(hndl, (LPCVOID)(baseEntity + (player * dw_EntityLoopOff)), &baseEntFinal, sizeof(DWORD), NULL);
    		ReadProcessMemory(hndl, (LPCVOID)(baseEntFinal + dw_team), &Team, sizeof(int), NULL);
    		ReadProcessMemory(hndl, (LPCVOID)(baseEntFinal + dw_HealthOff), &Health, sizeof(int), NULL);
    		ReadProcessMemory(hndl, (LPCVOID)(baseEntFinal + dw_posX), &Position, sizeof(float[3]), NULL);
    
    		}
    };

  2. #2
    squirr3l's Avatar
    Join Date
    Oct 2018
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    0
    Holy fuck talk about leaking handles...

Similar Threads

  1. [Patched] Working Payday 2 Hack. Come and get it while its hot!
    By Southflyer123 in forum Payday 2 Hacks & Cheats
    Replies: 106
    Last Post: 08-01-2014, 04:55 PM
  2. [Patched] Team D : CFNA,CFEU and CFPH (7/10/2012) Bug Fixed and Working Fine! STW
    By Jeovante in forum CrossFire Hacks & Cheats
    Replies: 145
    Last Post: 07-10-2012, 05:46 PM
  3. [Detected] ESP-Only Works in v1.7
    By selim98 in forum Call of Duty 4 - Modern Warfare (MW) Hacks
    Replies: 208
    Last Post: 06-16-2011, 02:27 PM
  4. [Solved] Combat arms only works in America, Europe and Japan?
    By micro961 in forum Combat Arms Help
    Replies: 16
    Last Post: 06-12-2011, 07:21 PM
  5. Wallhack that only appears while Spectating and in Killcam
    By HACKINGPIE in forum Call of Duty Modern Warfare 2 Help
    Replies: 5
    Last Post: 02-07-2010, 07:55 PM