From 25f9756f040c3a0f40a2799251c45d8fcf6ef360 Mon Sep 17 00:00:00 2001 From: Yimura <24669514+Yimura@users.noreply.github.com> Date: Sat, 12 Nov 2022 00:38:28 +0100 Subject: [PATCH] feat(ScriptEventHandler): Block switch player to animal (#581) --- src/core/enums.hpp | 2 +- src/core/globals.hpp | 7 +++++++ src/hooks/protections/script_event_handler.cpp | 11 +++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/core/enums.hpp b/src/core/enums.hpp index 0472f88e..7ab7a787 100644 --- a/src/core/enums.hpp +++ b/src/core/enums.hpp @@ -143,6 +143,7 @@ namespace big ClearWantedLevel = 1449852136, ForceMission = -283041276, // ), Var0.f_2, 1)) ForceMission2 = -1908874529, + GiveCollectible = -1178972880, // DLC_SUM20_HIDDEN_COLLECTIBLES xref GtaBanner = 145637109, // NETWORK::NETWORK_IS_SCRIPT_ACTIVE("BUSINESS_BATTLES", -1, true, 0) second one NetworkBail = 1674887089, // NETWORK::NETWORK_BAIL(16, 0, 0); xref func PersonalVehicleDestroyed = -1838276770, // PLYVEH_INS_DES1 @@ -158,7 +159,6 @@ namespace big TransactionError = -768108950, // NETWORK_RECEIVE_PLAYER_JOBSHARE_CASH VehicleKick = -714268990, // PIM_RFMOC Kick = 1674887089, - GiveCollectible = -1178972880, // DLC_SUM20_HIDDEN_COLLECTIBLES xref ChangeMCRole = 656530441, // _PLAYSTATS_CHANGE_MC_ROLE DisableRecording = 867047895, // GET_FINAL_RENDERED_CAM_COORD MCTeleport = -555356783, // NETWORK::NETWORK_HASH_FROM_PLAYER_HANDLE(PLAYER::PLAYER_ID()) == (first one) diff --git a/src/core/globals.hpp b/src/core/globals.hpp index 6193f3c4..85955ed7 100644 --- a/src/core/globals.hpp +++ b/src/core/globals.hpp @@ -73,6 +73,7 @@ namespace big pair send_to_location{}; pair sound_spam{}; pair spectate{}; + pair switch_player_model{}; pair transaction_error{}; pair tse_freeze{}; pair tse_sender_mismatch{}; @@ -131,6 +132,7 @@ namespace big bool send_to_location = true; bool sound_spam = true; bool spectate = true; + bool switch_player_model = true; bool transaction_error = true; bool vehicle_kick = true; bool teleport_to_warehouse = true; @@ -502,6 +504,8 @@ namespace big script_handler.sound_spam.notify = script_handler_j["sound_spam"]["notify"]; script_handler.spectate.log = script_handler_j["spectate"]["log"]; script_handler.spectate.notify = script_handler_j["spectate"]["notify"]; + script_handler.switch_player_model.log = script_handler_j["switch_player_model"]["log"]; + script_handler.switch_player_model.notify = script_handler_j["switch_player_model"]["notify"]; script_handler.transaction_error.log = script_handler_j["transaction_error"]["log"]; script_handler.transaction_error.notify = script_handler_j["transaction_error"]["notify"]; script_handler.tse_freeze.log = script_handler_j["tse_freeze"]["log"]; @@ -545,6 +549,7 @@ namespace big script_handler.send_to_location = script_handler_j["send_to_location"]; script_handler.sound_spam = script_handler_j["sound_spam"]; script_handler.spectate = script_handler_j["spectate"]; + script_handler.switch_player_model = script_handler_j["switch_player_model"]; script_handler.transaction_error = script_handler_j["transaction_error"]; script_handler.vehicle_kick = script_handler_j["vehicle_kick"]; script_handler.teleport_to_warehouse = script_handler_j["teleport_to_warehouse"]; @@ -781,6 +786,7 @@ namespace big { "send_to_location", return_notify_pair(script_handler_notifications.send_to_location) }, { "sound_spam", return_notify_pair(script_handler_notifications.sound_spam) }, { "spectate", return_notify_pair(script_handler_notifications.spectate) }, + { "switch_player_model", return_notify_pair(script_handler_notifications.switch_player_model) }, { "transaction_error", return_notify_pair(script_handler_notifications.transaction_error) }, { "tse_freeze", return_notify_pair(script_handler_notifications.tse_freeze) }, { "tse_sender_mismatch", return_notify_pair(script_handler_notifications.tse_sender_mismatch) }, @@ -820,6 +826,7 @@ namespace big { "send_to_location", script_handler_protections.send_to_location }, { "sound_spam", script_handler_protections.sound_spam }, { "spectate", script_handler_protections.spectate }, + { "switch_player_model", script_handler_protections.switch_player_model }, { "transaction_error", script_handler_protections.transaction_error }, { "vehicle_kick", script_handler_protections.vehicle_kick }, { "teleport_to_warehouse", script_handler_protections.teleport_to_warehouse }, diff --git a/src/hooks/protections/script_event_handler.cpp b/src/hooks/protections/script_event_handler.cpp index d47b521c..06ada8ac 100644 --- a/src/hooks/protections/script_event_handler.cpp +++ b/src/hooks/protections/script_event_handler.cpp @@ -105,6 +105,17 @@ namespace big return true; } break; + case eRemoteEvent::GiveCollectible: + if (g->protections.script_events.switch_player_model) + { + if (args[2] == 8) + { + format_string(player_name, "Switch Player Model", notify.switch_player_model.log, notify.switch_player_model.notify); + + return true; + } + } + break; case eRemoteEvent::GtaBanner: if (g->protections.script_events.gta_banner) {