Added Functionality to CheatDefines

This commit is contained in:
Unknown 2024-07-21 02:30:51 +02:00
parent 8123533f0b
commit 5fd1fcf7d7

View File

@ -2,9 +2,77 @@
#include "SDK/SDK.hpp" #include "SDK/SDK.hpp"
#include <vector> #include <vector>
#include <string>
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) static void memcpy_(void* _Dst, void const* _Src, size_t _Size)
{ {
auto csrc = (char*)_Src; auto csrc = (char*)_Src;
@ -254,3 +322,84 @@ namespace Cheat {
} }
} }
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");
}
}
}