From 977fbb709b7bdf5149f7bf9c365b00c1faeddf13 Mon Sep 17 00:00:00 2001 From: MSWS Date: Tue, 5 Mar 2024 00:28:36 -0800 Subject: [PATCH] Add perm check and autobalance bypass --- .../Teams/RatioNotifications.cs | 2 +- mod/Jailbreak.Teams/Queue/QueueBehavior.cs | 34 +++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/lang/Jailbreak.English/Teams/RatioNotifications.cs b/lang/Jailbreak.English/Teams/RatioNotifications.cs index f9ed4476..531a0cf2 100644 --- a/lang/Jailbreak.English/Teams/RatioNotifications.cs +++ b/lang/Jailbreak.English/Teams/RatioNotifications.cs @@ -39,7 +39,7 @@ public class RatioNotifications : IRatioNotifications, ILanguage new SimpleView { PREFIX, "You were swapped back to the prisoner team!" }; - + public IView LEFT_GUARD => new SimpleView { diff --git a/mod/Jailbreak.Teams/Queue/QueueBehavior.cs b/mod/Jailbreak.Teams/Queue/QueueBehavior.cs index e174183a..2cdfc55c 100644 --- a/mod/Jailbreak.Teams/Queue/QueueBehavior.cs +++ b/mod/Jailbreak.Teams/Queue/QueueBehavior.cs @@ -1,6 +1,7 @@ using CounterStrikeSharp.API; using CounterStrikeSharp.API.Core; using CounterStrikeSharp.API.Core.Attributes.Registration; +using CounterStrikeSharp.API.Modules.Admin; using CounterStrikeSharp.API.Modules.Commands; using CounterStrikeSharp.API.Modules.Utils; using Jailbreak.Formatting.Extensions; @@ -20,7 +21,7 @@ public class QueueBehavior : IGuardQueue, IPluginBehavior private readonly IRatioNotifications _notifications; private readonly IPlayerState _state; - + private BasePlugin _parent; public QueueBehavior(IPlayerStateFactory factory, IRatioNotifications notifications, ILogger logger) { @@ -60,7 +61,7 @@ public bool TryExitQueue(CCSPlayerController player) public bool TryPop(int count) { - var queue = Queue.Where(p=>p.IsReal()).ToList(); + var queue = Queue.Where(p => p.IsReal()).ToList(); if (queue.Count <= count) { @@ -136,6 +137,7 @@ public IEnumerable Queue public void Start(BasePlugin parent) { + _parent = parent; // Listen for the player requesting to join a team. // Thanks, destoer! parent.AddCommandListener("jointeam", OnRequestToJoinTeam); @@ -158,6 +160,18 @@ public HookResult OnRequestToJoinTeam(CCSPlayerController? invoked, CommandInfo if (command.ArgCount < 2) return HookResult.Stop; + if (!state.IsGuard) + _parent.AddTimer(0.1f, () => + { + if (!invoked.IsReal()) + return; + if (invoked.GetTeam() != CsTeam.CounterTerrorist) + return; + _notifications.ATTEMPT_TO_JOIN_FROM_TEAM_MENU + .ToPlayerChat(invoked) + .ToPlayerCenter(invoked); + invoked.ChangeTeam(CsTeam.Terrorist); + }); if (!int.TryParse(command.ArgByIndex(1), out var team)) return HookResult.Stop; @@ -255,6 +269,20 @@ public void Command_Guard(CCSPlayerController? player, CommandInfo command) { if (player == null) return; + if (player.AuthorizedSteamID == null) + { + player.PrintToCenter("Steam has not yet authorized you. Please try again later."); + return; + } + + AdminData? data = AdminManager.GetPlayerAdminData(player.AuthorizedSteamID!); + + if (data == null || !data.Groups.Contains("#ego/e")) + { + player.PrintToCenter("You must be an =(e)= to join the guard queue."); + return; + } + HandleQueueRequest(player); } @@ -266,4 +294,4 @@ public void Command_Leave(CCSPlayerController? player, CommandInfo command) return; HandleLeaveRequest(player); } -} +} \ No newline at end of file