diff --git a/src/hacks/Spam.cpp b/src/hacks/Spam.cpp index cab053d6..4d72160e 100644 --- a/src/hacks/Spam.cpp +++ b/src/hacks/Spam.cpp @@ -15,7 +15,7 @@ CatVar spam_source(spam_enum, "spam", "0", "Chat Spam", "Defines source of spam CatVar random_order(CV_SWITCH, "spam_random", "0", "Random Order"); CatVar filename(CV_STRING, "spam_file", "spam.txt", "Spam file", "Spam file name. Each line should be no longer than 100 characters, file must be located in cathook data folder"); CatCommand reload("spam_reload", "Reload spam file", Reload); -CatVar spam_delay(CV_FLOAT, "spam_delay", "0.8", "Spam delay", "Delay between spam messages (in seconds)", 0.0f, 8.0f); +CatVar spam_delay(CV_INT, "spam_delay", "800", "Spam delay", "Delay between spam messages (in ms)", 0.0f, 8000.0f); static CatEnum voicecommand_enum({"DISABLED", "RANDOM", "MEDIC", "THANKS", "NICE SHOT", "CHEERS", "JEERS"}); CatVar voicecommand_spam(voicecommand_enum, "spam_voicecommand", "0", "Voice Command Spam", "Spams tf voice commands"); @@ -23,9 +23,10 @@ CatVar voicecommand_spam(voicecommand_enum, "spam_voicecommand", "0", "Voice Com CatVar teamname_spam(CV_SWITCH, "spam_teamname", "0", "Teamname Spam", "Spam changes the tournament name"); +std::chrono::time_point last_spam_point {}; + bool teamname_swap = false; int current_index { 0 }; -float last_spam { 0.0f }; TextFile file {}; const std::string teams[] = { "RED", "BLU" }; @@ -234,7 +235,7 @@ void CreateMove() { } else { safety_ticks = 0; } - if (last_spam > g_GlobalVars->curtime) last_spam = 0.0f; + const std::vector* source = nullptr; switch ((int)spam_source) { case 1: @@ -255,7 +256,7 @@ void CreateMove() { return; } if (!source || !source->size()) return; - if (g_GlobalVars->curtime - last_spam > float(spam_delay)) { + if (std::chrono::duration_cast(std::chrono::system_clock::now() - last_spam_point).count() > int(spam_delay)) { if (chat_stack::stack.empty()) { if (current_index >= source->size()) current_index = 0; if (random_order) current_index = rand() % source->size(); @@ -264,13 +265,10 @@ void CreateMove() { chat_stack::Say(spamString); current_index++; } + last_spam_point = std::chrono::system_clock::now(); } } -void Reset() { - last_spam = 0.0f; -} - void Reload() { file.Load(std::string(filename.GetString())); } diff --git a/src/hacks/Spam.h b/src/hacks/Spam.h index bab2173a..948b1a3e 100644 --- a/src/hacks/Spam.h +++ b/src/hacks/Spam.h @@ -27,7 +27,6 @@ extern CatCommand reload; void Init(); void CreateMove(); -void Reset(); void Reload(); }}} diff --git a/src/hooks/others.cpp b/src/hooks/others.cpp index dc699288..16cb0298 100644 --- a/src/hooks/others.cpp +++ b/src/hooks/others.cpp @@ -457,7 +457,6 @@ void LevelInit_hook(void* _this, const char* newmap) { g_IEngine->ClientCmd_Unrestricted("exec cat_matchexec"); hacks::shared::aimbot::Reset(); chat_stack::Reset(); - hacks::shared::spam::Reset(); hacks::shared::anticheat::ResetEverything(); original(_this, newmap); } @@ -469,7 +468,6 @@ void LevelShutdown_hook(void* _this) { g_Settings.bInvalid = true; hacks::shared::aimbot::Reset(); chat_stack::Reset(); - hacks::shared::spam::Reset(); hacks::shared::anticheat::ResetEverything(); original(_this); }