|
| 1 | +using CounterStrikeSharp.API.Core; |
| 2 | +using CounterStrikeSharp.API.Modules.Commands; |
| 3 | +using CounterStrikeSharp.API.Core.Attributes; |
| 4 | +using System.Text.Json.Serialization; |
| 5 | + |
| 6 | +namespace Game_Manager; |
| 7 | + |
| 8 | + |
| 9 | +public class GameBMangerConfig : BasePluginConfig |
| 10 | +{ |
| 11 | + [JsonPropertyName("DisableRadio")] public bool DisableRadio { get; set; } = false; |
| 12 | + [JsonPropertyName("DisablePing")] public bool DisablePing { get; set; } = false; |
| 13 | + [JsonPropertyName("DisableChatWheel")] public bool DisableChatWheel { get; set; } = false; |
| 14 | + [JsonPropertyName("DisableKillfeed")] public bool DisableKillfeed { get; set; } = false; |
| 15 | + [JsonPropertyName("DisableWinOrLosePanel")] public bool DisableWinOrLosePanel { get; set; } = false; |
| 16 | + [JsonPropertyName("DisableWinOrLoseSound")] public bool DisableWinOrLoseSound { get; set; } = false; |
| 17 | + [JsonPropertyName("IgnoreJoinTeamMessages")] public bool IgnoreJoinTeamMessages { get; set; } = false; |
| 18 | + [JsonPropertyName("IgnoreDefaultDisconnectMessages")] public bool IgnoreDefaultDisconnectMessages { get; set; } = false; |
| 19 | +} |
| 20 | + |
| 21 | +public class GameBManger : BasePlugin, IPluginConfig<GameBMangerConfig> |
| 22 | +{ |
| 23 | + public override string ModuleName => "Game Manager"; |
| 24 | + public override string ModuleVersion => "1.0.0"; |
| 25 | + public override string ModuleAuthor => "Gold KingZ"; |
| 26 | + public override string ModuleDescription => "Block/Hide , Messages , Ping , Radio , Connect , Disconnect , Sounds"; |
| 27 | + |
| 28 | + public GameBMangerConfig Config { get; set; } |
| 29 | + |
| 30 | + public void OnConfigParsed(GameBMangerConfig config) |
| 31 | + { |
| 32 | + Config = config; |
| 33 | + } |
| 34 | + private string[] RadioArray = new string[] { |
| 35 | + "coverme", |
| 36 | + "takepoint", |
| 37 | + "holdpos", |
| 38 | + "regroup", |
| 39 | + "followme", |
| 40 | + "takingfire", |
| 41 | + "go", |
| 42 | + "fallback", |
| 43 | + "sticktog", |
| 44 | + "getinpos", |
| 45 | + "stormfront", |
| 46 | + "report", |
| 47 | + "roger", |
| 48 | + "enemyspot", |
| 49 | + "needbackup", |
| 50 | + "sectorclear", |
| 51 | + "inposition", |
| 52 | + "reportingin", |
| 53 | + "getout", |
| 54 | + "negative", |
| 55 | + "enemydown", |
| 56 | + "sorry", |
| 57 | + "cheer", |
| 58 | + "compliment", |
| 59 | + "thanks", |
| 60 | + "go_a", |
| 61 | + "go_b", |
| 62 | + "needrop", |
| 63 | + "deathcry" |
| 64 | + }; |
| 65 | + |
| 66 | + public override void Load(bool hotReload) |
| 67 | + { |
| 68 | + |
| 69 | + //AddCommandListener("chatwheel_ping", CommandListener_chatwheelping); |
| 70 | + //AddCommandListener("playerradio", CommandListener_playerradio); |
| 71 | + AddCommandListener("player_ping", CommandListener_Ping); |
| 72 | + AddCommandListener("playerchatwheel", CommandListener_chatwheel); |
| 73 | + //RegisterEventHandler<EventPlayerDisconnect>(OnPlayerDisconnect, HookMode.Pre); |
| 74 | + //RegisterEventHandler<EventPlayerTeam>(OnPlayerTeam, HookMode.Pre); |
| 75 | + RegisterEventHandler<EventRoundEnd>((@event, info) => |
| 76 | + { |
| 77 | + if (!Config.DisableWinOrLoseSound || @event == null)return HookResult.Continue; |
| 78 | + |
| 79 | + info.DontBroadcast = true; |
| 80 | + |
| 81 | + return HookResult.Continue; |
| 82 | + }, HookMode.Pre); |
| 83 | + RegisterEventHandler<EventCsWinPanelRound>((@event, info) => |
| 84 | + { |
| 85 | + if (!Config.DisableWinOrLosePanel || @event == null)return HookResult.Continue; |
| 86 | + |
| 87 | + info.DontBroadcast = true; |
| 88 | + |
| 89 | + return HookResult.Continue; |
| 90 | + }, HookMode.Pre); |
| 91 | + RegisterEventHandler<EventPlayerDisconnect>((@event, info) => |
| 92 | + { |
| 93 | + if (!Config.IgnoreDefaultDisconnectMessages || @event == null)return HookResult.Continue; |
| 94 | + |
| 95 | + info.DontBroadcast = true; |
| 96 | + |
| 97 | + return HookResult.Continue; |
| 98 | + }, HookMode.Pre); |
| 99 | + RegisterEventHandler<EventPlayerTeam>((@event, info) => |
| 100 | + { |
| 101 | + if (!Config.IgnoreJoinTeamMessages || @event == null)return HookResult.Continue; |
| 102 | + |
| 103 | + info.DontBroadcast = true; |
| 104 | + |
| 105 | + return HookResult.Continue; |
| 106 | + }, HookMode.Pre); |
| 107 | + RegisterEventHandler<EventPlayerDeath>((@event, info) => |
| 108 | + { |
| 109 | + if (!Config.DisableKillfeed || @event == null)return HookResult.Continue; |
| 110 | + |
| 111 | + info.DontBroadcast = true; |
| 112 | + |
| 113 | + return HookResult.Continue; |
| 114 | + }, HookMode.Pre); |
| 115 | + for (int i = 0; i < RadioArray.Length; i++) |
| 116 | + { |
| 117 | + AddCommandListener(RadioArray[i], CommandListener_RadioCommands); |
| 118 | + } |
| 119 | + } |
| 120 | + private HookResult CommandListener_Ping(CCSPlayerController? player, CommandInfo info) |
| 121 | + { |
| 122 | + if(!Config.DisablePing || player == null || !player.IsValid)return HookResult.Continue; |
| 123 | + |
| 124 | + return HookResult.Handled; |
| 125 | + } |
| 126 | + |
| 127 | + private HookResult CommandListener_chatwheel(CCSPlayerController? player, CommandInfo info) |
| 128 | + { |
| 129 | + if(!Config.DisableChatWheel || player == null || !player.IsValid)return HookResult.Continue; |
| 130 | + |
| 131 | + return HookResult.Handled; |
| 132 | + } |
| 133 | + private HookResult CommandListener_RadioCommands(CCSPlayerController? player, CommandInfo info) |
| 134 | + { |
| 135 | + if(!Config.DisableRadio || player == null || !player.IsValid)return HookResult.Continue; |
| 136 | + |
| 137 | + return HookResult.Handled; |
| 138 | + } |
| 139 | +} |
0 commit comments