My WorldToScreen keeps return false - ESP

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

DeniCevap

Newbie
Apr 9, 2015
2
62
0
EDIT: I posted in the wrong subforum! Posting this in the C++ subforum

I've done it a bit different than Fleep's tutorial.. But it should be the same "functions". (my english is not that good btw)

My esp finds every player, checks if they are in the other team, and if they have a HP higher than 2 it will draw an box around them. But my W2S functions returns false all the time...

Can I get some help?

C++:
#ifndef _FUNCTIONS
#define _CRT_SECURE_NO_WARNINGS

#include "ProcMem.h"
#include "Engine.h"
using namespace std;

ProcMem P;

//Offsets
//Player Related Stuff
#define LocalPlayer 0x00A4A98C
#define EntityList 0x049EC194 
#define EntLoopDistance = 0x10;

#define TeamOffset 0xF0
#define HealthOffset 0xFC
#define vecOrigin 0x134

//Matrixes
#define BoneMatrix 0xA78
#define ViewMatrix_1 0x4A058D4 
#define ViewMatrix_2 0x4A059E4 
#define ViewMatrix_3 0x4A05CF4

//Classes

WorldConversionMatrix_t W2S_M;
Inc entList[32];

Inc::Inc(){}
Engine::Engine(){}


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));

}


//Init Memory Vars
void Engine::Init()
{
	P.Process("csgo.exe");
	dwClient = P.Module("client.dll");
	//our player
	dwLocalPlayer = P.Read<DWORD>(dwClient + LocalPlayer);
	//myTeam = P.Read<int>(dwLocalPlayer + TeamOffset);
	

	//Init Window && Drawing Vars
	window = FindWindow(0, "Counter-Strike: Global Offensive");
	HD = GetDC(window);
	GetWindowRect(FindWindow(NULL, "Counter-Strike: Global Offensive"), &rectangle);
	brush = CreateSolidBrush(RGB(255, 100, 0));
	textColor = RGB(255, 50, 50);
}

void Engine::GetInfo()
{
	for (int i = 1; i != 64; i++)
	{
		dwEntityList = P.Read<DWORD>((dwClient + EntityList) + (i * 0x10));

		if (!dwEntityList) break;

		i_team = P.Read<int>(dwLocalPlayer + TeamOffset);
		e_team = P.Read<int>(dwEntityList + TeamOffset);

		if (e_team != i_team)
		{
			iPos = P.Read<Vector3>(dwLocalPlayer + 0x134);
			W2S_M = P.Read<WorldConversionMatrix_t>(dwClient + ViewMatrix_1);
			entList[i_Count].ePos = P.Read<Vector3>(dwEntityList + 0x134);
			entList[i_Count].iHealth = P.Read<int>(dwEntityList + HealthOffset);
		}
		i_Count++;
	}
}

bool Engine::WorldConversion(Vector3 src, float * dst)
{
	dst[0] = W2S_M.flMatrix[0][0] * src.x + W2S_M.flMatrix[0][1] * src.y + W2S_M.flMatrix[0][2] * src.z + W2S_M.flMatrix[0][3];
	dst[1] = W2S_M.flMatrix[1][0] * src.x + W2S_M.flMatrix[1][1] * src.y + W2S_M.flMatrix[1][2] * src.z + W2S_M.flMatrix[1][3];

	float View = W2S_M.flMatrix[2][0] * src.x + W2S_M.flMatrix[2][1] * src.y + W2S_M.flMatrix[2][2] * src.z + W2S_M.flMatrix[2][3];

	if (View < 0.01f)
		return false;

	float invw = 1.0f / View;
	dst[0] *= invw;
	dst[1] *= invw;

	float width = rectangle.right - rectangle.left;
	float height = rectangle.bottom - rectangle.top;

	float x = width / 2;
	float y = height / 2;

	x += 0.5f * dst[0] * width + 0.5f;
	y -= 0.5f * dst[1] * height + 0.5f;

	dst[0] = x;
	dst[1] = y;

	return true;
}

void Engine::DrawRect(int x, int y, int w, int h)
{
	RECT rect = { x, y, x + w, y + h };
	FillRect(HD, &rect, brush);
}

void Engine::DrawText2D(int x, int y, COLORREF color, const char* text)
{
	SetTextAlign(HD, TA_CENTER | TA_NOUPDATECP);

	SetBkColor(HD, RGB(0, 0, 0));
	SetBkMode(HD, TRANSPARENT);

	SetTextColor(HD, color);

	SelectObject(HD, font);

	TextOutA(HD, x, y, text, strlen(text));

	DeleteObject(font);
}

void Engine::DrawInfo(int x, int y, int distance, int Health)
{
	int width = 19100 / distance, height = 53000 / distance;

	DrawRect(x - (width / 2), y - (height), width, 1);
	DrawRect(x - (width / 2), y - (height), 1, height);
	DrawRect((x - (width / 2) + width), y - (height), 1, height);
	DrawRect(x - (width / 2), y - (height)+height, width + 1, 1);

	std::stringstream ss, hp;
	ss << (int)distance / 35;
	hp << Health;

	char * distanceInfo = new char[ss.str().size() + 1];
	strcpy(distanceInfo, ss.str().c_str());

	char * HealthInfo = new char[hp.str().size() + 1];
	strcpy(HealthInfo, hp.str().c_str());

	DrawText2D(x - 10, y - (height + 17), textColor, "HP:");
	DrawText2D(x + 15, y - (height + 17), textColor, HealthInfo);

	DrawText2D(x - 12, y + 1, textColor, "Dist:(");

	//Resize For Distance
	if (distance / 35 > 100)
	{
		DrawText2D(x + 18, y + 1, textColor, distanceInfo);
		DrawText2D(x + 40, y + 1, textColor, "m)");
	}
	else if (distance / 35 < 10)
	{
		DrawText2D(x + 13, y + 1, textColor, distanceInfo);
		DrawText2D(x + 27, y + 1, textColor, "m)");
	}
	else
	{
		DrawText2D(x + 15, y + 1, textColor, distanceInfo);
		DrawText2D(x + 33, y + 1, textColor, "m)");
	}

	delete[] HealthInfo, distanceInfo;
}

void Engine::ESP()
{
	for (int i = 1; i != i_Count; i++)
	{
		float enemyPos[3];
		enemyPos[0] = P.Read<float>(dwEntityList + (vecOrigin));
		enemyPos[1] = P.Read<float>(dwEntityList + (vecOrigin + 0x4));
		enemyPos[2] = P.Read<float>(dwEntityList + (vecOrigin + 0x8));

		float myPos[3];
		myPos[0] = P.Read<float>(dwLocalPlayer + (vecOrigin));
		myPos[1] = P.Read<float>(dwLocalPlayer + (vecOrigin + 0x4));
		myPos[2] = P.Read<float>(dwLocalPlayer + (vecOrigin + 0x8));

		if (entList[i].iHealth > 2 && WorldConversion(entList[i].ePos, enemyPos))
		{
			DrawInfo(enemyPos[0], enemyPos[1], Get3dDistance(myPos, enemyPos), entList[i].iHealth);
		}
	}
}

Inc::~Inc(){}
Engine::~Engine(){}

#endif
 
Last edited:

till0sch

Respected Hacker
Dank Tier VIP
Dank Tier Donator
Oct 14, 2012
1,104
12,593
51
next time wait until your thread gets moved instead of creating two
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods