From cc91ad4ea43ec79bc0b98b45597e22328e91dbf0 Mon Sep 17 00:00:00 2001 From: lonelybud <139460769+lonelybud@users.noreply.github.com> Date: Wed, 15 May 2024 21:08:48 +0530 Subject: [PATCH] elegant crash complete protection (#3109) --- src/core/enums.hpp | 1 + src/hooks/protections/script_event_handler.cpp | 18 +++++++++++++++++- src/services/players/player.hpp | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/core/enums.hpp b/src/core/enums.hpp index 2f87ff3b..802224ae 100644 --- a/src/core/enums.hpp +++ b/src/core/enums.hpp @@ -186,6 +186,7 @@ namespace big TSECommand = 800157557, // CnCTG_IN_BF TSECommandRotateCam = 225624744, // != 29) && f + TSECommandSound = 385726943, Notification = -642704387, NotificationMoneyBanked = 94410750, // TICK_TC_BANK diff --git a/src/hooks/protections/script_event_handler.cpp b/src/hooks/protections/script_event_handler.cpp index 6ae966af..c2ca2fbb 100644 --- a/src/hooks/protections/script_event_handler.cpp +++ b/src/hooks/protections/script_event_handler.cpp @@ -215,12 +215,28 @@ namespace big } break; case eRemoteEvent::TSECommand: - if (g.protections.script_events.rotate_cam && static_cast(args[3]) == eRemoteEvent::TSECommandRotateCam && !NETWORK::NETWORK_IS_ACTIVITY_SESSION()) + { + if (NETWORK::NETWORK_IS_ACTIVITY_SESSION()) + break; + + if (g.protections.script_events.rotate_cam && static_cast(args[3]) == eRemoteEvent::TSECommandRotateCam) { g.reactions.rotate_cam.process(plyr); return true; } + + if (g.protections.script_events.sound_spam && static_cast(args[3]) == eRemoteEvent::TSECommandSound) + { + if (!plyr || plyr->m_play_sound_rate_limit_tse.process()) + { + if (plyr->m_play_sound_rate_limit_tse.exceeded_last_process()) + g.reactions.sound_spam.process(plyr); + return true; + } + } + break; + } case eRemoteEvent::SendToCayoPerico: if (g.protections.script_events.send_to_location && args[4] == 0) { diff --git a/src/services/players/player.hpp b/src/services/players/player.hpp index 3d7d3275..16018b76 100644 --- a/src/services/players/player.hpp +++ b/src/services/players/player.hpp @@ -67,6 +67,7 @@ namespace big rate_limiter m_host_migration_rate_limit{2s, 15}; rate_limiter m_play_sound_rate_limit{1s, 10}; + rate_limiter m_play_sound_rate_limit_tse{5s, 2}; rate_limiter m_invites_rate_limit{10s, 2}; rate_limiter m_radio_request_rate_limit{5s, 2};