From 5fd1fcf7d7cd6b546c8181839d1fd054e63f5241 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 21 Jul 2024 02:30:51 +0200 Subject: [PATCH] Added Functionality to CheatDefines --- EscapeTheBackroomsGUiTest/CheatDefines.h | 151 ++++++++++++++++++++++- 1 file changed, 150 insertions(+), 1 deletion(-) diff --git a/EscapeTheBackroomsGUiTest/CheatDefines.h b/EscapeTheBackroomsGUiTest/CheatDefines.h index 3182818..95492af 100644 --- a/EscapeTheBackroomsGUiTest/CheatDefines.h +++ b/EscapeTheBackroomsGUiTest/CheatDefines.h @@ -2,9 +2,77 @@ #include "SDK/SDK.hpp" #include +#include +struct boolF +{ + bool value = false; + std::string reason = ""; + + boolF(bool value, std::string reason) + { + this->value = value; + this->reason = reason; + } + + boolF(bool value) + { + this->value = value; + } + + operator bool() + { + return value; + } + + operator std::string() + { + return reason; + } + + void operator=(boolF& other) + { + this->value = other.value; + this->reason = other.reason; + } +}; + +struct boolFW +{ + bool value = false; + std::wstring reason = L""; + + boolFW(bool value, std::wstring reason) + { + this->value = value; + this->reason = reason; + } + + boolFW(bool value) + { + this->value = value; + } + + operator bool() + { + return value; + } + + operator std::wstring() + { + return reason; + } + + void operator=(boolFW& other) + { + this->value = other.value; + this->reason = other.reason; + } +}; + +namespace Functions +{ -namespace Functions { static void memcpy_(void* _Dst, void const* _Src, size_t _Size) { auto csrc = (char*)_Src; @@ -253,4 +321,85 @@ namespace Cheat { return reinterpret_cast(StaticConstructObject_Internal(¶ms)); } +} + + + +namespace FunctionsSpecial +{ + + SDK::APlayerController* GetLocalPlayerController(SDK::UWorld* World) + { + if (!World->OwningGameInstance || !&World->OwningGameInstance->LocalPlayers || World->OwningGameInstance->LocalPlayers[0]) { return nullptr; } + + auto LocalPlayer = World->OwningGameInstance->LocalPlayers[0]; + + auto PlayerController = (SDK::AMP_PlayerController_C*)LocalPlayer->PlayerController; + if (!PlayerController) { return nullptr; } + + + return PlayerController; + } + + //Check if Localplayer is the Host of the Session + bool IsLocalHost(SDK::UWorld* World) + { + return (World->AuthorityGameMode != nullptr); + } + + bool IsPlayerLocal(SDK::UWorld* World, SDK::ACharacter* Player) + { + auto PlayerCCLocal = GetLocalPlayerController(World); + + if (!PlayerCCLocal || !PlayerCCLocal->Character) + return false; + + return PlayerCCLocal->Character == Player; + } + + //Kicks an Player + boolF KickPlayer(SDK::UWorld* World, SDK::ACharacter* Player, std::string Reason) + { + auto GameMode = (SDK::AMP_GameMode_C*)World->AuthorityGameMode; + + if (GameMode) + { + if (IsPlayerLocal(World, Player)) + { + return boolF(false, "Canīt Kick Player, Because You Canīt Kick Yourself"); + } + + auto PlayerState = Player->PlayerState; + GameMode->KickPlayer(PlayerState, Player->GetOwner(), (SDK::AMP_PlayerController_C*)Player->Controller, true, true); + + return boolF(true, std::format("Kicking Player: {}, Reason: {}", PlayerStuff::Player::SanitizeString(PlayerState->PlayerNamePrivate.ToString()), Reason)); + } + else + { + return boolF(false, "Canīt Kick Player, Because your not the Host"); + } + } + + //Kicks an Player + boolFW KickPlayer(SDK::UWorld* World, SDK::ACharacter* Player, std::wstring Reason) + { + auto GameMode = (SDK::AMP_GameMode_C*)World->AuthorityGameMode; + + if (GameMode) + { + if (IsPlayerLocal(World, Player)) + { + return boolFW(false, L"Canīt Kick Player, Because You Canīt Kick Yourself"); + } + + auto PlayerState = Player->PlayerState; + GameMode->KickPlayer(PlayerState, Player->GetOwner(), (SDK::AMP_PlayerController_C*)Player->Controller, true, true); + + return boolFW(true, std::format(L"Kicking Player: {}, Reason: {}", PlayerStuff::Player::SanitizeWString(PlayerState->PlayerNamePrivate.ToWString()), Reason)); + } + else + { + return boolFW(false, L"Canīt Kick Player, Because your not the Host"); + } + } } \ No newline at end of file