diff --git a/src/FiveStack.Entities/MatchMember.cs b/src/FiveStack.Entities/MatchMember.cs index a3e2d73..16758ee 100644 --- a/src/FiveStack.Entities/MatchMember.cs +++ b/src/FiveStack.Entities/MatchMember.cs @@ -6,4 +6,7 @@ public class MatchMember public string? steam_id { get; set; } = ""; public bool captain { get; set; } = false; public Guid match_lineup_id { get; set; } = Guid.Empty; + public bool is_banned { get; set; } = false; + public bool is_gagged { get; set; } = false; + public bool is_muted { get; set; } = false; } diff --git a/src/FiveStack.Events/GagPlayer.cs b/src/FiveStack.Events/GagPlayer.cs new file mode 100644 index 0000000..3faa723 --- /dev/null +++ b/src/FiveStack.Events/GagPlayer.cs @@ -0,0 +1,45 @@ +using CounterStrikeSharp.API.Core; +using CounterStrikeSharp.API.Modules.Commands; +using CounterStrikeSharp.API.Modules.Utils; +using FiveStack.Entities; +using FiveStack.Utilities; + +namespace FiveStack; + +public partial class FiveStackPlugin +{ + public HookResult GagPlayer(CCSPlayerController? player, CommandInfo info) + { + if (player == null || !player.IsValid) + { + return HookResult.Continue; + } + + MatchManager? match = _matchService.GetCurrentMatch(); + + if (match == null) + { + return HookResult.Continue; + } + + MatchData? matchData = match?.GetMatchData(); + + if (matchData == null) + { + return HookResult.Continue; + } + + MatchMember? member = MatchUtility.GetMemberFromLineup(matchData, player); + + if (member != null) + { + if (member.is_gagged) + { + player.PrintToChat($" {ChatColors.Red}You are gagged"); + return HookResult.Stop; + } + } + + return HookResult.Continue; + } +} diff --git a/src/FiveStack.Events/PlayerChat.cs b/src/FiveStack.Events/PlayerChat.cs index 75f0edc..564434c 100644 --- a/src/FiveStack.Events/PlayerChat.cs +++ b/src/FiveStack.Events/PlayerChat.cs @@ -1,6 +1,5 @@ using CounterStrikeSharp.API.Core; using CounterStrikeSharp.API.Modules.Commands; -using FiveStack.Entities; namespace FiveStack; @@ -14,7 +13,6 @@ public HookResult OnPlayerChat(CCSPlayerController? player, CommandInfo info) } MatchManager? match = _matchService.GetCurrentMatch(); - MatchMap? currentMap = match?.GetCurrentMap(); if (match == null) { diff --git a/src/FiveStack.Services/MatchManager.cs b/src/FiveStack.Services/MatchManager.cs index 5768b38..0eb4eae 100644 --- a/src/FiveStack.Services/MatchManager.cs +++ b/src/FiveStack.Services/MatchManager.cs @@ -2,6 +2,7 @@ using CounterStrikeSharp.API.Core; using CounterStrikeSharp.API.Modules.Cvars; using CounterStrikeSharp.API.Modules.Utils; +using CounterStrikeSharp.API.ValveConstants.Protobuf; using FiveStack.Entities; using FiveStack.Enums; using FiveStack.Utilities; @@ -150,7 +151,12 @@ public void UpdateMapStatus(eMapStatus status) var currentMap = GetCurrentMap(); - if (_currentMapStatus == eMapStatus.Warmup && status != eMapStatus.Warmup && currentMap != null && currentMap.order == 1) + if ( + _currentMapStatus == eMapStatus.Warmup + && status != eMapStatus.Warmup + && currentMap != null + && currentMap.order == 1 + ) { SendUpdatedMatchLineups(); } @@ -171,7 +177,6 @@ public void UpdateMapStatus(eMapStatus status) return; } - if (currentMap == null) { break; @@ -433,6 +438,28 @@ public async void EnforceMemberTeam(CCSPlayerController player, CsTeam? currentT Server.NextFrame(() => { + MatchMember? member = MatchUtility.GetMemberFromLineup(matchData, player); + + if (member == null) + { + return; + } + + if (member.is_banned) + { + player.Disconnect(NetworkDisconnectionReason.NETWORK_DISCONNECT_BANADDED); + return; + } + + if (member.is_muted) + { + player.VoiceFlags = VoiceFlags.Muted; + } + else + { + player.VoiceFlags = VoiceFlags.Normal; + } + Guid? lineup_id = MatchUtility.GetPlayerLineup(matchData, player); if (lineup_id == null) diff --git a/src/FiveStackPlugin.cs b/src/FiveStackPlugin.cs index 5b74ba5..b56185b 100644 --- a/src/FiveStackPlugin.cs +++ b/src/FiveStackPlugin.cs @@ -66,6 +66,9 @@ public override void Load(bool hotReload) AddCommandListener("say", OnPlayerChat, HookMode.Post); + AddCommandListener("say", GagPlayer, HookMode.Pre); + AddCommandListener("say_team", GagPlayer, HookMode.Pre); + Server.NextFrame(() => { _gameServer.Message(HudDestination.Alert, "5Stack Loaded");