add Level Restriction

This commit is contained in:
D1GQ committed 2026-02-05 15:45:55 -06:00
1 parent c7fef12e7d
commit 958e1371a6
3 files changed
+16 -3

No files matched your search

@@ -12,6 +12,16 @@ internal sealed class SetLevelHandler : RPCHandler
{
internal override byte CallId => (byte)RpcCalls.SetLevel;
internal override void Handle(PlayerControl? sender, MessageReader reader)
{
uint level = reader.ReadPackedUInt32() + 1;
if (level < BetterGameSettings.KickLevelBelow.GetInt())
{
sender.Kick(setReasonInfo: $" is level {level}, level must be equal or above {BetterGameSettings.KickLevelBelow.GetInt()} to join");
}
}
internal override bool HandleAntiCheatCancel(PlayerControl? sender, MessageReader reader)
{
if (sender.DataIsCollected() == true && sender.BetterData().AntiCheatInfo.HasSetLevel && !GameState.IsLocalGame && GameState.IsVanillaServer)
@@ -31,9 +41,9 @@ internal sealed class SetLevelHandler : RPCHandler
internal override void HandleAntiCheat(PlayerControl? sender, MessageReader reader)
{
uint level = reader.ReadPackedUInt32();
uint level = reader.ReadPackedUInt32() + 1;
if (level + 1 > BetterGameSettings.DetectedLevelAbove.GetInt())
if (level > BetterGameSettings.DetectedLevelAbove.GetInt())
{
if (BetterNotificationManager.NotifyCheat(sender, string.Format(Translator.GetString("AntiCheat.InvalidLevelRPC"), level)))
{
@@ -19,6 +19,7 @@ class BetterGameSettings
internal static OptionCheckboxItem? UseBanWordListOnlyLobby;
internal static OptionIntItem? HideAndSeekImpNum;
internal static OptionIntItem? DetectedLevelAbove;
internal static OptionIntItem? KickLevelBelow;
internal static OptionCheckboxItem? DetectCheatClients;
internal static OptionCheckboxItem? DetectInvalidRPCs;
internal static OptionStringItem? RoleRandomizer;
@@ -44,7 +45,7 @@ internal static class GameSettingsPatch
internal static void SetupSettings(bool IsPreload = false)
{
// Use 1700 next ID
// Use 1800 next ID
BetterSettingsTab = OptionTab.Create(3, "BetterSetting", "BetterSetting.Description", Color.green);
@@ -71,6 +72,7 @@ internal static class GameSettingsPatch
OptionTitleItem.Create(BetterSettingsTab, "BetterSetting.TextHeader.Detections");
BetterGameSettings.CensorDetectionReason = OptionCheckboxItem.Create(1300, BetterSettingsTab, "BetterSetting.Setting.CensorDetectionReason", false);
BetterGameSettings.DetectedLevelAbove = OptionIntItem.Create(600, BetterSettingsTab, "BetterSetting.Setting.DetectedLevelAbove", (100, 10000, 5), 500, ("Lv ", ""));
BetterGameSettings.KickLevelBelow = OptionIntItem.Create(1700, BetterSettingsTab, "BetterSetting.Setting.KickLevelBelow", (0, 10000, 1), 0, ("Lv ", ""));
BetterGameSettings.DetectCheatClients = OptionCheckboxItem.Create(700, BetterSettingsTab, "BetterSetting.Setting.DetectCheatClients", true);
BetterGameSettings.DetectInvalidRPCs = OptionCheckboxItem.Create(800, BetterSettingsTab, "BetterSetting.Setting.DetectInvalidRPCs", true);
}
+1
View File
@@ -87,6 +87,7 @@
"BetterSetting.Setting.ShowRoleForClients": "Show role in name for clients",
"BetterSetting.Setting.CensorDetectionReason": "Censor detection reason",
"BetterSetting.Setting.DetectedLevelAbove": "Detected player levels >",
"BetterSetting.Setting.KickLevelBelow": "Kick player levels <",
"BetterSetting.Setting.DetectCheatClients": "Detect cheat clients",
"BetterSetting.Setting.DetectInvalidRPCs": "Detect invalid RPCs",
"BetterSetting.Setting.RoleRandomizer": "Randomizer",