std::chrono spam delay
This commit is contained in:
parent
c610cc67c8
commit
dcfbb3e062
@ -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<std::chrono::system_clock> 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<std::string>* 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::milliseconds>(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()));
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ extern CatCommand reload;
|
||||
|
||||
void Init();
|
||||
void CreateMove();
|
||||
void Reset();
|
||||
void Reload();
|
||||
|
||||
}}}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user