-
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathmain.cpp
More file actions
140 lines (117 loc) · 4.4 KB
/
Copy pathmain.cpp
File metadata and controls
140 lines (117 loc) · 4.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#include "GSIServer.h"
#include "Updater.h"
#include "UIAccess.h"
#include "Rebuild.h"
#include "ErScripts.h"
#include "Overlay.h"
#define APP_VERSION "1.2.4"
int main(int argc, char* argv[]) {
Logger::EnableANSIColors();
if (!IsDebuggerPresent()) {
/* Rebuild */
//bool should_rebuild = true;
//for (int i = 1; i < argc; ++i) {
// if (std::string(argv[i]) == "--run") {
// should_rebuild = false;
// break;
// }
//}
// Check if program already running
CreateMutexA(0, FALSE, "Local\\erscripts");
if (GetLastError() == ERROR_ALREADY_EXISTS) {
//Rebuild::cleanupTempFiles();
Updater::cleanupTempFiles();
MessageBoxA(NULL, "ErScripts is already running!", 0, MB_OK);
return -1;
}
// Rebuild or unpack
//Rebuild rebuilder;
//if (!rebuilder.rebuildAndRelaunch(should_rebuild)) {
// std::cout << "[*] Rebuild or unpack failed. Continuing with current binary.\n";
//}
//if (should_rebuild) {
// return 0; // Exit after relaunch
//}
/* Auto updater */
Updater updater(APP_VERSION, "emp0ry", "cs2-ErScripts", "ErScripts");
if (updater.checkAndUpdate())
return 0;
/* Ui Access */
DWORD dwErr = PrepareForUIAccess();
if (dwErr != ERROR_SUCCESS) {
Logger::logWarning(std::format("Failed to prepare for UI Access: {}", dwErr));
std::cout << "[*] Press Enter to exit...";
std::cin.get();
return -1;
}
}
SetConsoleTitleA(std::format("ErScripts {}", APP_VERSION).c_str());
std::cout << "[-] *---------------------------------------*" << std::endl;
std::cout << "[>] | ErScripts by emp0ry |" << std::endl;
std::cout << "[>] | GitHub - https://github.com/emp0ry/ |" << std::endl;
std::cout << "[-] *---------------------------------------*" << std::endl;
cfg->load("default");
gradient.setConfig(cfg->gradient);
ErScripts es;
es.Initalization();
Overlay overlay;
overlay.run();
GSIServer gsi;
gsi.run();
es.ConsoleLogStream();
es.AutoAccept();
es.BombTimer();
es.KillSound();
es.RoundStartAlert();
es.InitBinds();
es.PixelTrigger();
es.Crosshair();
es.RGBCrosshair();
es.KnifeSwitch();
es.AutoPistol();
es.AntiAfk();
es.CS2Binds();
es.KillSay();
es.AutoStop();
es.ChatSpammer();
while (!globals::finish) {
static int prevExitBind = cfg->erScriptsExitBind;
static std::chrono::steady_clock::time_point changeTime;
static bool isDelayActive = false;
if (prevExitBind != cfg->erScriptsExitBind) {
prevExitBind = cfg->erScriptsExitBind;
changeTime = std::chrono::steady_clock::now();
isDelayActive = true;
}
else if (isDelayActive) {
auto now = std::chrono::steady_clock::now();
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(now - changeTime).count();
if (elapsed >= 2000) {
isDelayActive = false;
}
}
else {
if (GetAsyncKeyState(cfg->erScriptsExitBind) & 0x8000) globals::finish = true;
}
/* Update Ping */
if (ErScripts::GetWindowState && ErScripts::GetCursorState()) {
static auto lastUpdate = std::chrono::steady_clock::now();
auto now = std::chrono::steady_clock::now();
std::chrono::duration<float> elapsed = now - lastUpdate;
if (cfg->watermarkState) {
if (elapsed.count() >= cfg->watermarkPingUpdateRate) {
ErScripts::CommandsSender(5, "sys_info;clear");
lastUpdate = now;
}
}
if (cfg->sniperCrosshairState || cfg->recoilCrosshairState || cfg->angleBindState) {
if (elapsed.count() >= 1.5f) {
ErScripts::CommandsSender(5, "print_changed_convars; clear; echo *---------------------------------------*; echo | ErScripts by emp0ry |; echo | GitHub - github.com/emp0ry/ |; echo *---------------------------------------*");
}
}
}
std::this_thread::sleep_for(std::chrono::milliseconds(25));
}
gsi.stop();
exit(0);
}