Skip to content

Commit af8f7e2

Browse files
committed
added esp name
1 parent 41fd1b6 commit af8f7e2

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

src/base.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ bool Base::Data::Settings::EnableEspArmor;
101101
float Base::Data::Settings::EspArmorColor[4] = { 0.0f, 0.0f, 0.8f, 1.0f };
102102
float Base::Data::Settings::EspArmorDmgColor[4] = { 0.05, 0.0f, 0.0f, 1.0f };
103103

104+
bool Base::Data::Settings::EnableEspName = false;
105+
float Base::Data::Settings::EspNameColor[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
106+
float Base::Data::Settings::EspNameOutlineColor[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
107+
104108
DWORD WINAPI ExitThread(LPVOID lpReserved);
105109

106110
void Base::Init(HMODULE hMod)

src/base.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ namespace Base
120120
extern bool EnableEspArmor;
121121
extern float EspArmorColor[4];
122122
extern float EspArmorDmgColor[4];
123+
124+
extern bool EnableEspName;
125+
extern float EspNameColor[4];
126+
extern float EspNameOutlineColor[4];
123127
}
124128

125129
namespace Keys

src/hacks/ESP_Info.cpp

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ void Base::Hacks::ESP_Info(playerinfo_t* p_info)
1010
float BarWidth = Height / 2;
1111
float BarHeight = Height / 20;
1212
float Padding = Height / 14;
13-
float Space = 0.0f;
13+
float SpaceDown = 0.0f;
14+
float SpaceUp = 0.0f;
15+
float FontHeight = 18.0f;
16+
float FontWidth = FontHeight * 0.325f;
1417

1518
if (Data::Settings::EnableEspHealth)
1619
{
17-
Space += Padding;
18-
ImVec2 HealthBarPos = ImVec2(p_info->pos2D.x - BarWidth / 2, p_info->pos2D.y + Space);
20+
SpaceDown += Padding;
21+
ImVec2 HealthBarPos = ImVec2(p_info->pos2D.x - BarWidth / 2, p_info->pos2D.y + SpaceDown);
1922
ImVec2 HealthBarEnd = ImVec2(p_info->pos2D.x + BarWidth / 2, HealthBarPos.y + BarHeight);
2023
ImColor DamageColor = ImColor(Data::Settings::EspHealthDmgColor[0], Data::Settings::EspHealthDmgColor[1], Data::Settings::EspHealthDmgColor[2], Data::Settings::EspHealthDmgColor[3]);
2124
ImColor HealthColor = ImColor(Data::Settings::EspHealthColor[0], Data::Settings::EspHealthColor[1], Data::Settings::EspHealthColor[2], Data::Settings::EspHealthColor[3]);
@@ -33,13 +36,13 @@ void Base::Hacks::ESP_Info(playerinfo_t* p_info)
3336

3437
Draw->AddQuadFilled(p1, p2, p3, p4, HealthColor);
3538

36-
Space += BarHeight;
39+
SpaceDown += BarHeight;
3740
}
3841

3942
if (Data::Settings::EnableEspArmor)
4043
{
41-
Space += Padding;
42-
ImVec2 ArmorBarPos = ImVec2(p_info->pos2D.x - BarWidth / 2, p_info->pos2D.y + Space);
44+
SpaceDown += Padding;
45+
ImVec2 ArmorBarPos = ImVec2(p_info->pos2D.x - BarWidth / 2, p_info->pos2D.y + SpaceDown);
4346
ImVec2 ArmorBarEnd = ImVec2(p_info->pos2D.x + BarWidth / 2, ArmorBarPos.y + BarHeight);
4447
ImColor DamageColor = ImColor(Data::Settings::EspArmorDmgColor[0], Data::Settings::EspArmorDmgColor[1], Data::Settings::EspArmorDmgColor[2], Data::Settings::EspArmorDmgColor[3]);
4548
ImColor ArmorColor = ImColor(Data::Settings::EspArmorColor[0], Data::Settings::EspArmorColor[1], Data::Settings::EspArmorColor[2], Data::Settings::EspArmorColor[3]);
@@ -57,6 +60,20 @@ void Base::Hacks::ESP_Info(playerinfo_t* p_info)
5760

5861
Draw->AddQuadFilled(p1, p2, p3, p4, ArmorColor);
5962

60-
Space += BarHeight;
63+
SpaceDown += BarHeight;
64+
}
65+
66+
if (Data::Settings::EnableEspName)
67+
{
68+
SpaceUp += Padding;
69+
size_t TextLength = strlen(p_info->ent->name);
70+
float TextWidth = (float)TextLength * FontWidth;
71+
float TextHeight = FontHeight;
72+
ImColor TextColor = ImColor(Data::Settings::EspNameColor[0], Data::Settings::EspNameColor[1], Data::Settings::EspNameColor[2], Data::Settings::EspNameColor[3]);
73+
ImVec2 TextPos = ImVec2(p_info->headpos2D.x - (TextWidth / 2), p_info->headpos2D.y - SpaceUp - TextHeight);
74+
75+
Draw->AddText(TextPos, TextColor, (const char*)p_info->ent->name);
76+
77+
SpaceUp += TextHeight;
6178
}
6279
}

src/hooks/SwapBuffers.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ BOOL __stdcall Base::Hooks::SwapBuffers(_In_ HDC hdc)
6060
ImGui::Begin("ImGui Window");
6161
ImGui::Text("Test ImGUI Window");
6262

63+
ImGui::Checkbox("ESP Name", &Data::Settings::EnableEspName);
64+
6365
ImGui::Checkbox("ESP Armor", &Data::Settings::EnableEspArmor);
6466

6567
ImGui::Checkbox("Enable ESP Team", &Data::Settings::EnableEspTeam);

0 commit comments

Comments
 (0)