mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-19 15:51:52 +00:00
27 lines
987 B
C#
27 lines
987 B
C#
using BetterAmongUs.Utilities;
|
|
using BetterAmongUs.Modules;
|
|
using BetterAmongUs.Patches.Gameplay.UI.Settings;
|
|
using HarmonyLib;
|
|
|
|
namespace BetterAmongUs.Patches.Gameplay.Anticheat;
|
|
|
|
[HarmonyPatch]
|
|
internal static class CheckPlayerLevelPatch
|
|
{
|
|
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.FixedUpdate))]
|
|
[HarmonyPostfix]
|
|
private static void PlayerControl_FixedUpdate_Postfix(PlayerControl __instance)
|
|
{
|
|
if (__instance.Data == null)
|
|
return;
|
|
|
|
if (GameState.IsHost && GameState.IsLobby)
|
|
{
|
|
// Kick players below minimum level
|
|
if (!__instance.IsLocalPlayer() && BetterGameSettings.KickLevel.GetBool() && __instance.Data.PlayerLevel < BetterGameSettings.KickLevelBelow.GetInt())
|
|
{
|
|
__instance.TryKick(setReasonInfo: $" is level {__instance.Data.PlayerLevel}, level must be equal or above {BetterGameSettings.KickLevelBelow.GetInt()} to join");
|
|
}
|
|
}
|
|
}
|
|
} |