Skip to content

Commit 78ed5dc

Browse files
committed
Some improvements
1 parent d72a436 commit 78ed5dc

22 files changed

+1082
-1082
lines changed

ErScripts/AutoAccept.cpp

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,66 @@
11
#include "ErScripts.h"
22

33
void ErScripts::AutoAccept() {
4-
std::thread([this]() {
5-
const std::vector<int> targetColor = { 54, 183, 82 };
4+
std::thread([this]() {
5+
const std::vector<int> targetColor = { 54, 183, 82 };
66

7-
while (!globals::finish) {
8-
if (cfg->autoAcceptState) {
9-
if (foundMatch) {
10-
foundMatch = false;
7+
while (!globals::finish) {
8+
if (cfg->autoAcceptState) {
9+
if (foundMatch) {
10+
foundMatch = false;
1111

12-
POINT mousePos;
13-
GetCursorPos(&mousePos);
12+
POINT mousePos;
13+
GetCursorPos(&mousePos);
1414

15-
bool isInCS2 = GetWindowState();
15+
bool isInCS2 = GetWindowState();
1616

17-
// Maximize cs2
18-
ShowWindow(hwnd, SW_RESTORE);
19-
SetForegroundWindow(hwnd);
17+
// Maximize cs2
18+
ShowWindow(hwnd, SW_RESTORE);
19+
SetForegroundWindow(hwnd);
2020

21-
bool colorState = false;
22-
auto startTime = std::chrono::steady_clock::now();
21+
bool colorState = false;
22+
auto startTime = std::chrono::steady_clock::now();
2323

24-
while (std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() - startTime).count() <= cfg->autoAcceptWaitingTime) {
25-
int buttonX = static_cast<int>(round(globals::width / 2.f + globals::posX)), buttonY = static_cast<int>(round(globals::height / 2.215f + globals::posY));
24+
while (std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() - startTime).count() <= cfg->autoAcceptWaitingTime) {
25+
int buttonX = static_cast<int>(round(globals::width / 2.f + globals::posX)), buttonY = static_cast<int>(round(globals::height / 2.215f + globals::posY));
2626

27-
if (GetWindowState()) {
28-
std::vector color = GetPixelColor(buttonX, buttonY);
27+
if (GetWindowState()) {
28+
std::vector color = GetPixelColor(buttonX, buttonY);
2929

30-
if (isColorSimilar(targetColor, color, 20)) {
31-
colorState = true;
32-
Logger::logInfo("AutoAccept button clicking");
30+
if (isColorSimilar(targetColor, color, 20)) {
31+
colorState = true;
32+
Logger::logInfo("AutoAccept button clicking");
3333

34-
// Move cursor to correct position
35-
SetCursorPos(buttonX, buttonY);
36-
std::this_thread::sleep_for(std::chrono::milliseconds(1));
34+
// Move cursor to correct position
35+
SetCursorPos(buttonX, buttonY);
36+
std::this_thread::sleep_for(std::chrono::milliseconds(1));
3737

38-
// Click accept button
39-
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
40-
std::this_thread::sleep_for(std::chrono::milliseconds((std::rand() % 32) + 16));
41-
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
42-
}
43-
else if (colorState) {
44-
break;
45-
}
46-
}
47-
std::this_thread::sleep_for(std::chrono::milliseconds(1));
48-
}
38+
// Click accept button
39+
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
40+
std::this_thread::sleep_for(std::chrono::milliseconds((std::rand() % 32) + 16));
41+
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
42+
}
43+
else if (colorState) {
44+
break;
45+
}
46+
}
47+
std::this_thread::sleep_for(std::chrono::milliseconds(1));
48+
}
4949

50-
if (!isInCS2) {
51-
Keyboard(56, true, false);
52-
std::this_thread::sleep_for(std::chrono::milliseconds((std::rand() % 32) + 16));
53-
Keyboard(15, true, false);
54-
std::this_thread::sleep_for(std::chrono::milliseconds((std::rand() % 32) + 16));
55-
Keyboard(15, false, false);
56-
std::this_thread::sleep_for(std::chrono::milliseconds((std::rand() % 32) + 16));
57-
Keyboard(56, false, false);
58-
}
50+
if (!isInCS2) {
51+
Keyboard(56, true, false);
52+
std::this_thread::sleep_for(std::chrono::milliseconds((std::rand() % 32) + 16));
53+
Keyboard(15, true, false);
54+
std::this_thread::sleep_for(std::chrono::milliseconds((std::rand() % 32) + 16));
55+
Keyboard(15, false, false);
56+
std::this_thread::sleep_for(std::chrono::milliseconds((std::rand() % 32) + 16));
57+
Keyboard(56, false, false);
58+
}
5959

60-
SetCursorPos(mousePos.x, mousePos.y);
61-
}
62-
}
63-
std::this_thread::sleep_for(std::chrono::microseconds(15625));
64-
}
65-
}).detach();
60+
SetCursorPos(mousePos.x, mousePos.y);
61+
}
62+
}
63+
std::this_thread::sleep_for(std::chrono::microseconds(15625));
64+
}
65+
}).detach();
6666
}

ErScripts/BombTime.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
#include "ErScripts.h"
22

33
void ErScripts::BombTimer() {
4-
std::thread([this]() {
5-
while (!globals::finish) {
6-
if (cfg->bombTimerState) {
7-
static bool isbombTimerStarted = false;
8-
static std::chrono::system_clock::time_point bombPlantedTime;
4+
std::thread([this]() {
5+
while (!globals::finish) {
6+
if (cfg->bombTimerState) {
7+
static bool isbombTimerStarted = false;
8+
static std::chrono::system_clock::time_point bombPlantedTime;
99

10-
if (globals::bombState) {
11-
if (!isbombTimerStarted) {
12-
bombPlantedTime = std::chrono::system_clock::now();
13-
isbombTimerStarted = true;
14-
}
10+
if (globals::bombState) {
11+
if (!isbombTimerStarted) {
12+
bombPlantedTime = std::chrono::system_clock::now();
13+
isbombTimerStarted = true;
14+
}
1515

16-
if (isbombTimerStarted) {
17-
globals::bombTime = 40000 - std::chrono::duration<double, std::milli>(std::chrono::system_clock::now() - bombPlantedTime).count();
18-
if (globals::bombTime <= 0) globals::bombTime = 0.0l;
19-
}
20-
}
21-
else {
22-
globals::bombTime = 0.0l;
23-
isbombTimerStarted = false;
24-
}
25-
}
26-
std::this_thread::sleep_for(std::chrono::microseconds(15625));
27-
}
28-
}).detach();
16+
if (isbombTimerStarted) {
17+
globals::bombTime = 40000 - std::chrono::duration<double, std::milli>(std::chrono::system_clock::now() - bombPlantedTime).count();
18+
if (globals::bombTime <= 0) globals::bombTime = 0.0l;
19+
}
20+
}
21+
else {
22+
globals::bombTime = 0.0l;
23+
isbombTimerStarted = false;
24+
}
25+
}
26+
std::this_thread::sleep_for(std::chrono::microseconds(15625));
27+
}
28+
}).detach();
2929
}

ErScripts/ChatSpammer.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
#include "ErScripts.h"
22

33
void ErScripts::ChatSpammer() {
4-
std::thread([this]() {
5-
bool state = false;
6-
bool statePrev = false;
4+
std::thread([this]() {
5+
bool state = false;
6+
bool statePrev = false;
77

8-
while (!globals::finish) {
9-
if (cfg->chatSpammerState) {
10-
bool bindState = GetAsyncKeyState(cfg->chatSpammerBind) & 0x8000;
8+
while (!globals::finish) {
9+
if (cfg->chatSpammerState) {
10+
bool bindState = GetAsyncKeyState(cfg->chatSpammerBind) & 0x8000;
1111

12-
if (bindState && !statePrev) {
13-
state = !state;
14-
}
12+
if (bindState && !statePrev) {
13+
state = !state;
14+
}
1515

16-
statePrev = bindState;
16+
statePrev = bindState;
1717

18-
if (state || !cfg->chatSpammerBind) {
19-
CommandsSender(9, std::format("say {}", cfg->chatSpammerText));
20-
}
21-
}
22-
std::this_thread::sleep_for(std::chrono::milliseconds(50));
23-
}
24-
}).detach();
18+
if (state || !cfg->chatSpammerBind) {
19+
CommandsSender(9, std::format("say {}", cfg->chatSpammerText));
20+
}
21+
}
22+
std::this_thread::sleep_for(std::chrono::milliseconds(50));
23+
}
24+
}).detach();
2525
}

ErScripts/Config.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
void Config::load(const std::string& filename) {
44
if (!std::filesystem::exists("configs"))
5-
std::filesystem::create_directory("configs");
5+
std::filesystem::create_directory("configs");
66

77
std::ifstream file("configs\\" + filename + ".json");
88
if (!file.is_open()) return;
@@ -31,8 +31,8 @@ void Config::load(const std::string& filename) {
3131
/* Sniper Crosshair */
3232
read(json["sniper-crosshair"]["state"], sniperCrosshairState);
3333

34-
/* Recoil Crosshair */
35-
read(json["recoil-crosshair"]["state"], recoilCrosshairState);
34+
/* Recoil Crosshair */
35+
read(json["recoil-crosshair"]["state"], recoilCrosshairState);
3636

3737
/* RGB Crosshair */
3838
read(json["rgb-crosshair"]["state"], rgbCrosshairState);
@@ -87,14 +87,14 @@ void Config::load(const std::string& filename) {
8787
read(json["auto-stop"]["toggle"]["state"], autoStopToggleState);
8888

8989
/* Chat Spammer */
90-
read(json["chat-spammer"]["state"], chatSpammerState);
91-
read(json["chat-spammer"]["bind"], chatSpammerBind);
92-
read(json["chat-spammer"]["text"], chatSpammerText);
90+
read(json["chat-spammer"]["state"], chatSpammerState);
91+
read(json["chat-spammer"]["bind"], chatSpammerBind);
92+
read(json["chat-spammer"]["text"], chatSpammerText);
9393

94-
/* Angle Bind */
95-
read(json["angle-bind"]["state"], angleBindState);
96-
read(json["angle-bind"]["bind"], angleBindBind);
97-
read(json["angle-bind"]["degree"], angleBindDegree);
94+
/* Angle Bind */
95+
read(json["angle-bind"]["state"], angleBindState);
96+
read(json["angle-bind"]["bind"], angleBindBind);
97+
read(json["angle-bind"]["degree"], angleBindDegree);
9898

9999
/* Watermark */
100100
read(json["watermark"]["state"], watermarkState);
@@ -117,9 +117,9 @@ void Config::load(const std::string& filename) {
117117
read(json["gradient-manager"]["saturation"], gradient.saturation);
118118
read(json["gradient-manager"]["value"], gradient.value);
119119

120-
/* ErScripts Binds */
121-
read(json["er-scripts"]["menu"]["bind"], erScriptsMenuBind);
122-
read(json["er-scripts"]["exit"]["bind"], erScriptsExitBind);
120+
/* ErScripts Binds */
121+
read(json["er-scripts"]["menu"]["bind"], erScriptsMenuBind);
122+
read(json["er-scripts"]["exit"]["bind"], erScriptsExitBind);
123123

124124
/* Vsync */
125125
read(json["vsync"]["state"], vsyncState);
@@ -152,8 +152,8 @@ void Config::save(const std::string& filename) const {
152152
/* RGB Crosshair */
153153
json["rgb-crosshair"]["state"] = rgbCrosshairState;
154154

155-
/* Recoil Crosshair */
156-
json["recoil-crosshair"]["state"] = recoilCrosshairState;
155+
/* Recoil Crosshair */
156+
json["recoil-crosshair"]["state"] = recoilCrosshairState;
157157

158158
/* Keystrokes */
159159
json["keystrokes"]["state"] = keystrokesState;
@@ -204,15 +204,15 @@ void Config::save(const std::string& filename) const {
204204
json["auto-stop"]["bind"] = autoStopBind;
205205
json["auto-stop"]["toggle"]["state"] = autoStopToggleState;
206206

207-
/* Chat Spammer */
208-
json["chat-spammer"]["state"] = chatSpammerState;
209-
json["chat-spammer"]["bind"] = chatSpammerBind;
210-
json["chat-spammer"]["text"] = chatSpammerText;
207+
/* Chat Spammer */
208+
json["chat-spammer"]["state"] = chatSpammerState;
209+
json["chat-spammer"]["bind"] = chatSpammerBind;
210+
json["chat-spammer"]["text"] = chatSpammerText;
211211

212212
/* Angle Bind */
213-
json["angle-bind"]["state"] = angleBindState;
214-
json["angle-bind"]["bind"] = angleBindBind;
215-
json["angle-bind"]["degree"] = angleBindDegree;
213+
json["angle-bind"]["state"] = angleBindState;
214+
json["angle-bind"]["bind"] = angleBindBind;
215+
json["angle-bind"]["degree"] = angleBindDegree;
216216

217217
/* Watermark */
218218
json["watermark"]["state"] = watermarkState;
@@ -239,8 +239,8 @@ void Config::save(const std::string& filename) const {
239239
json["vsync"]["state"] = vsyncState;
240240

241241
/* ErScripts Binds */
242-
json["er-scripts"]["menu"]["bind"] = erScriptsMenuBind;
243-
json["er-scripts"]["exit"]["bind"] = erScriptsExitBind;
242+
json["er-scripts"]["menu"]["bind"] = erScriptsMenuBind;
243+
json["er-scripts"]["exit"]["bind"] = erScriptsExitBind;
244244

245245
if (!std::filesystem::exists("configs"))
246246
std::filesystem::create_directory("configs");

ErScripts/Config.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ class Config {
1515
/* Pixel Trigger */
1616
bool triggerState{ false };
1717
int triggerBind{ 0 };
18-
int triggerDisplacement[2]{ 1, 1 };
19-
int triggerThreshold{ 20 };
18+
int triggerDisplacement[2]{ 1, 1 };
19+
int triggerThreshold{ 20 };
2020
int triggerDelayMs{ 0 };
2121

2222
/* Auto Accept */
2323
bool autoAcceptState{ false };
24-
int autoAcceptWaitingTime{ 5 };
24+
int autoAcceptWaitingTime{ 5 };
2525

2626
/* Bomb Timer */
2727
bool bombTimerState{ false };
@@ -31,13 +31,13 @@ class Config {
3131
float bombTimerPos[2]{ 0, 0 };
3232

3333
/* Sniper Crosshair */
34-
bool sniperCrosshairState{ false };
34+
bool sniperCrosshairState{ false };
3535

3636
/* RGB Crosshair */
3737
bool rgbCrosshairState{ false };
3838

3939
/* Recoil Crosshair */
40-
bool recoilCrosshairState{ false };
40+
bool recoilCrosshairState{ false };
4141

4242
/* Keystrokes */
4343
bool keystrokesState{ false };
@@ -90,18 +90,18 @@ class Config {
9090
bool autoStopToggleState{ false };
9191

9292
/* Chat Spammer */
93-
bool chatSpammerState{ false };
94-
int chatSpammerBind{ 0 };
95-
std::string chatSpammerText{ "Enhance Your Skills with emp0ry.github.io/cs2-ErScripts/" };
93+
bool chatSpammerState{ false };
94+
int chatSpammerBind{ 0 };
95+
std::string chatSpammerText{ "Enhance Your Skills with emp0ry.github.io/cs2-ErScripts/" };
9696

9797
/* Angle Bind */
98-
bool angleBindState{ false };
99-
int angleBindBind{ 0 };
100-
float angleBindDegree{ 180.0f };
98+
bool angleBindState{ false };
99+
int angleBindBind{ 0 };
100+
float angleBindDegree{ 180.0f };
101101

102102
/* Watermark */
103-
bool watermarkState{ true };
104-
bool watermarkGradientState{ true };
103+
bool watermarkState{ true };
104+
bool watermarkGradientState{ true };
105105
float watermarkTransparency{ 1.0f };
106106
int watermarkPingUpdateRate{ 3 };
107107

@@ -119,8 +119,8 @@ class Config {
119119
bool vsyncState{ false };
120120

121121
/* ErScripts Binds */
122-
int erScriptsMenuBind{ VK_INSERT };
123-
int erScriptsExitBind{ VK_END };
122+
int erScriptsMenuBind{ VK_INSERT };
123+
int erScriptsExitBind{ VK_END };
124124

125125
private:
126126
template <typename T>

0 commit comments

Comments
 (0)