void ESP()
{
DWORD dwClient = Mem.Module("client.dll");
DWORD dwEngine = Mem.Module("engine.dll");
ReadProcessMemory(pHandle, (LPVOID)(dwClient + ViewMatrix), &W2S_M.flMatrix, sizeof(WorldToScreenMatrix_t), NULL);
GetWindowRect(FindWindow(NULL, "Counter-Strike: Global Offensive"), &m_Rect);
DWORD pLocal = Mem.Read<DWORD>(dwClient + dw_PlayerBase);
//int LocalTeam = Mem.Read<int>(pLocal + dw_teamOffset);
DWORD LocalTeam = ReadProcessMemory(pHandle, (LPVOID)(dw_PlayerBase + 0xF0), &LocalTeam, sizeof(LocalTeam), NULL);
int LocalHealth = Mem.Read<int>(pLocal + dw_healthOffset);
float LocalPosition[3];
LocalPosition[0] = Mem.Read<float>(pLocal + 0x134);
LocalPosition[1] = Mem.Read<float>(pLocal + 0x138);
LocalPosition[2] = Mem.Read<float>(pLocal + 0x13C);
for (int i = 0; i < 32; i++)
{
uintptr_t pEnemy = Mem.Read<uintptr_t>(dwClient + dw_EntityBase + (i * dw_EntityLoopDistance));
int EnemyTeam = ReadProcessMemory(pHandle, (LPVOID)(dw_EntityBase + 0xF0), &EnemyTeam, sizeof(EnemyTeam), NULL);
int EnemyHealth = Mem.Read<int>(pEnemy + dw_healthOffset);
float HeadPos[3];
float Position[3];
Position[0] = Mem.Read<float>(pEnemy + 0x134);
Position[1] = Mem.Read<float>(pEnemy + 0x138);
Position[2] = Mem.Read<float>(pEnemy + 0x13C);
uintptr_t BoneBase = Mem.Read<uintptr_t>(pEnemy + dw_BoneMatrix);
GetBonePos(BoneBase, 6, HeadPos);
float EnemyXYHeadPos[3];
float EnemyXY[3];
if (WorldToScreen(Position, EnemyXY) && WorldToScreen(HeadPos, EnemyXYHeadPos))
{
float Distance = Get3dDistance(LocalPosition, Position);
float Height = abs(EnemyXY[1] - EnemyXYHeadPos[1]);
float Width = Height / 2;
DrawBox(10, 10, 20, 20, 1, 255, 0, 0, 255);
DrawBox(EnemyXY[0] - (Width / 2), EnemyXY[1] - Height, Width, Height, 1, 255, 0, 0, 255);
}
}

typedef struct {
float flMatrix[4][4];
}WorldToScreenMatrix_t;
WorldToScreenMatrix_t W2S_M;
RECT m_Rect; //WORLD TO SCREEN RECT
bool WorldToScreen(float * from, float * to)
{
to[0] = W2S_M.flMatrix[0][0] * from[0] + W2S_M.flMatrix[0][1] * from[1] + W2S_M.flMatrix[0][2] * from[2] + W2S_M.flMatrix[0][3];
to[1] = W2S_M.flMatrix[1][0] * from[0] + W2S_M.flMatrix[1][1] * from[1] + W2S_M.flMatrix[1][2] * from[2] + W2S_M.flMatrix[1][3];
float w = W2S_M.flMatrix[3][0] * from[0] + W2S_M.flMatrix[3][1] * from[1] + W2S_M.flMatrix[3][2] * from[2] + W2S_M.flMatrix[3][3];
if (w < 0.01f)
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;
}
//and this in my ESP func:
GetWindowRect(FindWindow(NULL, "Counter-Strike: Global Offensive"), &m_Rect);
ReadProcessMemory(pHandle, (LPVOID)(dwClient + ViewMatrix), &W2S_M.flMatrix, sizeof(WorldToScreenMatrix_t), NULL);
DWORD pLocal = Mem.Read<DWORD>(dwClient + dw_PlayerBase); DWORD LocalTeam = ReadProcessMemory(pHandle, (LPVOID)(dw_PlayerBase + 0xF0), &LocalTeam, sizeof(LocalTeam), NULL);
uintptr_t pEnemy = Mem.Read<uintptr_t>(dwClient + dw_EntityBase + (i * dw_EntityLoopDistance)); int EnemyTeam = ReadProcessMemory(pHandle, (LPVOID)(dw_EntityBase + 0xF0), &EnemyTeam, sizeof(EnemyTeam), NULL);
void ESP()
{
if (callonOnce == false)
{
dwClient = Mem.Module("client.dll");
dwEngine = Mem.Module("engine.dll");
callonOnce = true;
}
W2S_M = Mem.Read<WorldToScreenMatrix_t>(dwClient + ViewMatrix);
DWORD pLocal = Mem.Read<DWORD>(dwClient + dw_PlayerBase);
//int LocalTeam = Mem.Read<int>(pLocal + dw_teamOffset);
DWORD LocalTeam = Mem.Read<DWORD>(pLocal + dw_teamOffset);
DWORD LocalHealth = Mem.Read<DWORD>(pLocal + dw_healthOffset);
float LocalPosition[3];
LocalPosition[0] = Mem.Read<float>(pLocal + 0x134);
LocalPosition[1] = Mem.Read<float>(pLocal + (0x134 + 0x4));
LocalPosition[2] = Mem.Read<float>(pLocal + (0x134 + 0x8));
for (int i = 0; i < 32; i++)
{
DWORD pEnemy = Mem.Read<DWORD>(dwClient + dw_EntityBase + (i * dw_EntityLoopDistance));
DWORD EnemyTeam = Mem.Read<DWORD>(pEnemy + dw_teamOffset);
DWORD EnemyHealth = Mem.Read<DWORD>(pEnemy + dw_healthOffset);
float HeadPos[3];
float Position[3];
Position[0] = Mem.Read<float>(pEnemy + 0x134);
Position[1] = Mem.Read<float>(pEnemy + (0x134 + 0x4));
Position[2] = Mem.Read<float>(pEnemy + (0x134 + 0x8));
DWORD BoneBase = Mem.Read<DWORD>(pEnemy + dw_BoneMatrix);
GetBonePos(BoneBase, 6, HeadPos);
float EnemyXYHeadPos[3];
float EnemyXY[3];
if (WorldToScreen(Position, EnemyXY))
{
float Distance = Get3dDistance(LocalPosition, Position);
float Height = 20000 / Distance;
float Width = 20000 / Distance;
Drawing::Rect(10, 10, 20, 20, D3DCOLOR_ARGB(255, 0, 255, 0));
Drawing::Rect(EnemyXY[0] - (Width / 2), EnemyXY[1] - Height, Width, Height, Color::White);
}
}
}
if (WorldToScreenM(EntityPlayer.Pos, W2SP) && WorldToScreenM(EntityPlayer.HeadPos, W2S_Head)) {
int height = abs(W2SP[1] - W2S_Head[1]);
int width = height / 2; //Or whatever you want.
CornerBox(W2SP[0] - (width / 2), W2SP[1] - height, width, height, Color.Enemy.R, Color.Enemy.G, Color.Enemy.B, 255);
void DrawBox(float x, float y, float width, float height, float px, int r, int g, int b, int a)
{
D3DXVECTOR2 points[5];
points[0] = D3DXVECTOR2(x, y);
points[1] = D3DXVECTOR2(x + width, y);
points[2] = D3DXVECTOR2(x + width, y + height);
points[3] = D3DXVECTOR2(x, y + height);
points[4] = D3DXVECTOR2(x, y);
DirectX.Line->SetWidth(1);
DirectX.Line->Draw(points, 5, D3DCOLOR_RGBA(r, g, b, a));
}
RECT W2S_Rect;
typedef struct {
float flMatrix[4][4];
}WorldToScreenMatrix_t;
WorldToScreenMatrix_t W2S_M;
bool WorldToScreen(float * from, float * to)
{
W2S_M = Mem.Read<WorldToScreenMatrix_t>(dwClient + ViewMatrix);
to[0] = W2S_M.flMatrix[0][0] * from[0] + W2S_M.flMatrix[0][1] * from[1] + W2S_M.flMatrix[0][2] * from[2] + W2S_M.flMatrix[0][3];
to[1] = W2S_M.flMatrix[1][0] * from[0] + W2S_M.flMatrix[1][1] * from[1] + W2S_M.flMatrix[1][2] * from[2] + W2S_M.flMatrix[1][3];
float w = W2S_M.flMatrix[3][0] * from[0] + W2S_M.flMatrix[3][1] * from[1] + W2S_M.flMatrix[3][2] * from[2] + W2S_M.flMatrix[3][3];
if (w < 0.01f)
return false;
float invw = 1.0f / w;
to[0] *= invw;
to[1] *= invw;
int width = (int)(W2S_Rect.right - W2S_Rect.left);
int height = (int)(W2S_Rect.bottom - W2S_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 + W2S_Rect.left;
to[1] = y + W2S_Rect.top;
return true;
}
GetWindowRect(FindWindow(NULL, "Counter-Strike: Global Offensive"), &W2S_Rect);
DWORD ViewMatrix = 0x4A3E664; //VIEWMATRIX DWORD dw_PlayerBase = 0x00A31504; DWORD dw_teamOffset = 0xFC; DWORD dw_healthOffset = 0xF0; DWORD dw_EntityBase = 0x04A4CAC4; DWORD dw_EntityLoopDistance = 0x10; DWORD dw_BoneMatrix = 0x2698; //Position Enemy: float Position[3]; Position[0] = Mem.Read<float>(pEnemy + 0x134); Position[1] = Mem.Read<float>(pEnemy + 0x138); Position[2] = Mem.Read<float>(pEnemy + 0x13C);