diff --git a/.gitignore b/.gitignore index 8359a57..870e2ac 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ obj/ .vs/ .git .vscode/ -.idea/ \ No newline at end of file +.idea/ +CS2-SimpleAdmin.sln.DotSettings.user +Modules/CS2-SimpleAdmin_ExampleModule/CS2-SimpleAdmin_ExampleModule.sln.DotSettings.user diff --git a/CS2-SimpleAdmin/Api/CS2_SimpleAdminApi.cs b/CS2-SimpleAdmin/Api/CS2_SimpleAdminApi.cs index 62449d5..3a83697 100644 --- a/CS2-SimpleAdmin/Api/CS2_SimpleAdminApi.cs +++ b/CS2-SimpleAdmin/Api/CS2_SimpleAdminApi.cs @@ -72,6 +72,40 @@ public class CS2_SimpleAdminApi : ICS2_SimpleAdminApi throw new ArgumentOutOfRangeException(nameof(penaltyType), penaltyType, null); } } + + public void IssuePenalty(SteamID steamid, CCSPlayerController? admin, PenaltyType penaltyType, string reason, int duration = -1) + { + switch (penaltyType) + { + case PenaltyType.Ban: + { + CS2_SimpleAdmin.Instance.AddBan(admin, steamid, duration, reason); + break; + } + case PenaltyType.Gag: + { + CS2_SimpleAdmin.Instance.AddGag(admin, steamid, duration, reason); + break; + } + case PenaltyType.Mute: + { + CS2_SimpleAdmin.Instance.AddMute(admin, steamid, duration, reason); + break; + } + case PenaltyType.Silence: + { + CS2_SimpleAdmin.Instance.AddSilence(admin, steamid, duration, reason); + break; + } + case PenaltyType.Warn: + { + CS2_SimpleAdmin.Instance.AddWarn(admin, steamid, duration, reason); + break; + } + default: + throw new ArgumentOutOfRangeException(nameof(penaltyType), penaltyType, null); + } + } public void LogCommand(CCSPlayerController? caller, string command) { diff --git a/CS2-SimpleAdmin/CS2-SimpleAdmin.cs b/CS2-SimpleAdmin/CS2-SimpleAdmin.cs index d768326..fc64b0c 100644 --- a/CS2-SimpleAdmin/CS2-SimpleAdmin.cs +++ b/CS2-SimpleAdmin/CS2-SimpleAdmin.cs @@ -19,7 +19,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig "CS2-SimpleAdmin" + (Helper.IsDebugBuild ? " (DEBUG)" : " (RELEASE)"); public override string ModuleDescription => "Simple admin plugin for Counter-Strike 2 :)"; public override string ModuleAuthor => "daffyy & Dliix66"; - public override string ModuleVersion => "1.7.2c"; + public override string ModuleVersion => "1.7.3a"; public override void Load(bool hotReload) { diff --git a/CS2-SimpleAdmin/CS2-SimpleAdmin.csproj b/CS2-SimpleAdmin/CS2-SimpleAdmin.csproj index 1759082..78d0918 100644 --- a/CS2-SimpleAdmin/CS2-SimpleAdmin.csproj +++ b/CS2-SimpleAdmin/CS2-SimpleAdmin.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/CS2-SimpleAdmin/Commands/basebans.cs b/CS2-SimpleAdmin/Commands/basebans.cs index a840b5d..7e0ad00 100644 --- a/CS2-SimpleAdmin/Commands/basebans.cs +++ b/CS2-SimpleAdmin/Commands/basebans.cs @@ -34,8 +34,6 @@ public partial class CS2_SimpleAdmin : _localizer?["sa_unknown"] ?? "Unknown"; reason = string.IsNullOrWhiteSpace(reason) ? _localizer?["sa_unknown"] ?? "Unknown" : reason; - - var time = Helper.ParsePenaltyTime(command.GetArg(2)); playersToTarget.ForEach(player => @@ -122,6 +120,42 @@ public partial class CS2_SimpleAdmin Helper.SendDiscordPenaltyMessage(caller, player, reason, time, PenaltyType.Ban, _localizer); } + internal void AddBan(CCSPlayerController? caller, SteamID steamid, int time, string reason, BanManager? banManager = null) + { + // Set default caller name if not provided + var callerName = !string.IsNullOrEmpty(caller?.PlayerName) + ? caller.PlayerName + : (_localizer?["sa_console"] ?? "Console"); + + var adminInfo = caller != null && caller.UserId.HasValue ? PlayersInfo[caller.UserId.Value] : null; + + var matches = Helper.GetPlayerFromSteamid64(steamid.SteamId64.ToString()); + var player = matches.Count == 1 ? matches.FirstOrDefault() : null; + + if (player != null && player.IsValid) + { + if (!caller.CanTarget(player)) + return; + + Ban(caller, player, time, reason, callerName, silent: true); + //command.ReplyToCommand($"Banned player {player.PlayerName}."); + } + else + { + if (!caller.CanTarget(steamid)) + return; + + // Asynchronous ban operation if player is not online or not found + Task.Run(async () => + { + int? penaltyId = await BanManager.AddBanBySteamid(steamid.SteamId64.ToString(), adminInfo, reason, time); + SimpleAdminApi?.OnPlayerPenaltiedAddedEvent(steamid, adminInfo, PenaltyType.Ban, reason, time, penaltyId); + }); + + Helper.SendDiscordPenaltyMessage(caller, steamid.SteamId64.ToString(), reason, time, PenaltyType.Ban, _localizer); + } + } + [RequiresPermissions("@css/ban")] [CommandHelper(minArgs: 1, usage: " [time in minutes/0 perm] [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)] public void OnAddBanCommand(CCSPlayerController? caller, CommandInfo command) @@ -399,6 +433,63 @@ public partial class CS2_SimpleAdmin Helper.SendDiscordPenaltyMessage(caller, player, reason, time, PenaltyType.Warn, _localizer); } + internal void AddWarn(CCSPlayerController? caller, SteamID steamid, int time, string reason, WarnManager? warnManager = null) + { + // Set default caller name if not provided + var callerName = !string.IsNullOrEmpty(caller?.PlayerName) + ? caller.PlayerName + : (_localizer?["sa_console"] ?? "Console"); + + var adminInfo = caller != null && caller.UserId.HasValue ? PlayersInfo[caller.UserId.Value] : null; + + var matches = Helper.GetPlayerFromSteamid64(steamid.SteamId64.ToString()); + var player = matches.Count == 1 ? matches.FirstOrDefault() : null; + + if (player != null && player.IsValid) + { + if (!caller.CanTarget(player)) + return; + + Warn(caller, player, time, reason, callerName); + //command.ReplyToCommand($"Banned player {player.PlayerName}."); + } + else + { + if (!caller.CanTarget(steamid)) + return; + + // Asynchronous ban operation if player is not online or not found + Task.Run(async () => + { + int? penaltyId = await WarnManager.AddWarnBySteamid(steamid.SteamId64.ToString(), adminInfo, reason, time); + SimpleAdminApi?.OnPlayerPenaltiedAddedEvent(steamid, adminInfo, PenaltyType.Warn, reason, time, penaltyId); + + // Check for warn thresholds and execute punish command if applicable + var totalWarns = await WarnManager.GetPlayerWarnsCount(steamid.SteamId64.ToString()); + if (Config.WarnThreshold.Count > 0) + { + string? punishCommand = null; + var lastKey = Config.WarnThreshold.Keys.Max(); + + if (totalWarns >= lastKey) + punishCommand = Config.WarnThreshold[lastKey]; + else if (Config.WarnThreshold.TryGetValue(totalWarns, out var value)) + punishCommand = value; + + if (!string.IsNullOrEmpty(punishCommand)) + { + await Server.NextFrameAsync(() => + { + Server.ExecuteCommand(punishCommand.Replace("STEAMID64", steamid.SteamId64.ToString())); + }); + } + } + }); + + Helper.SendDiscordPenaltyMessage(caller, steamid.SteamId64.ToString(), reason, time, PenaltyType.Warn, _localizer); + } + } + [RequiresPermissions("@css/kick")] [CommandHelper(minArgs: 1, usage: "", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)] public void OnUnwarnCommand(CCSPlayerController? caller, CommandInfo command) diff --git a/CS2-SimpleAdmin/Commands/basecomms.cs b/CS2-SimpleAdmin/Commands/basecomms.cs index b04f16f..75adc30 100644 --- a/CS2-SimpleAdmin/Commands/basecomms.cs +++ b/CS2-SimpleAdmin/Commands/basecomms.cs @@ -104,6 +104,41 @@ public partial class CS2_SimpleAdmin Helper.SendDiscordPenaltyMessage(caller, player, reason, time, PenaltyType.Gag, _localizer); } + + internal void AddGag(CCSPlayerController? caller, SteamID steamid, int time, string reason, MuteManager? muteManager = null) + { + // Set default caller name if not provided + var callerName = !string.IsNullOrEmpty(caller?.PlayerName) + ? caller.PlayerName + : (_localizer?["sa_console"] ?? "Console"); + + var adminInfo = caller != null && caller.UserId.HasValue ? PlayersInfo[caller.UserId.Value] : null; + + var matches = Helper.GetPlayerFromSteamid64(steamid.SteamId64.ToString()); + var player = matches.Count == 1 ? matches.FirstOrDefault() : null; + + if (player != null && player.IsValid) + { + if (!caller.CanTarget(player)) + return; + + Gag(caller, player, time, reason, callerName, silent: true); + } + else + { + if (!caller.CanTarget(steamid)) + return; + + // Asynchronous ban operation if player is not online or not found + Task.Run(async () => + { + int? penaltyId = await MuteManager.AddMuteBySteamid(steamid.SteamId64.ToString(), adminInfo, reason, time, 3); + SimpleAdminApi?.OnPlayerPenaltiedAddedEvent(steamid, adminInfo, PenaltyType.Gag, reason, time, penaltyId); + }); + + Helper.SendDiscordPenaltyMessage(caller, steamid.SteamId64.ToString(), reason, time, PenaltyType.Gag, _localizer); + } + } [RequiresPermissions("@css/chat")] [CommandHelper(minArgs: 1, usage: " [time in minutes/0 perm] [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)] @@ -402,6 +437,41 @@ public partial class CS2_SimpleAdmin // Log the mute command and respond to the command Helper.LogCommand(caller, command); } + + internal void AddMute(CCSPlayerController? caller, SteamID steamid, int time, string reason, MuteManager? muteManager = null) + { + // Set default caller name if not provided + var callerName = !string.IsNullOrEmpty(caller?.PlayerName) + ? caller.PlayerName + : (_localizer?["sa_console"] ?? "Console"); + + var adminInfo = caller != null && caller.UserId.HasValue ? PlayersInfo[caller.UserId.Value] : null; + + var matches = Helper.GetPlayerFromSteamid64(steamid.SteamId64.ToString()); + var player = matches.Count == 1 ? matches.FirstOrDefault() : null; + + if (player != null && player.IsValid) + { + if (!caller.CanTarget(player)) + return; + + Mute(caller, player, time, reason, callerName, silent: true); + } + else + { + if (!caller.CanTarget(steamid)) + return; + + // Asynchronous ban operation if player is not online or not found + Task.Run(async () => + { + int? penaltyId = await MuteManager.AddMuteBySteamid(steamid.SteamId64.ToString(), adminInfo, reason, time, 1); + SimpleAdminApi?.OnPlayerPenaltiedAddedEvent(steamid, adminInfo, PenaltyType.Mute, reason, time, penaltyId); + }); + + Helper.SendDiscordPenaltyMessage(caller, steamid.SteamId64.ToString(), reason, time, PenaltyType.Mute, _localizer); + } + } [RequiresPermissions("@css/chat")] [CommandHelper(minArgs: 1, usage: "", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)] @@ -635,6 +705,41 @@ public partial class CS2_SimpleAdmin // Log the silence command and respond to the command Helper.LogCommand(caller, command); } + + internal void AddSilence(CCSPlayerController? caller, SteamID steamid, int time, string reason, MuteManager? muteManager = null) + { + // Set default caller name if not provided + var callerName = !string.IsNullOrEmpty(caller?.PlayerName) + ? caller.PlayerName + : (_localizer?["sa_console"] ?? "Console"); + + var adminInfo = caller != null && caller.UserId.HasValue ? PlayersInfo[caller.UserId.Value] : null; + + var matches = Helper.GetPlayerFromSteamid64(steamid.SteamId64.ToString()); + var player = matches.Count == 1 ? matches.FirstOrDefault() : null; + + if (player != null && player.IsValid) + { + if (!caller.CanTarget(player)) + return; + + Silence(caller, player, time, reason, callerName, silent: true); + } + else + { + if (!caller.CanTarget(steamid)) + return; + + // Asynchronous ban operation if player is not online or not found + Task.Run(async () => + { + int? penaltyId = await MuteManager.AddMuteBySteamid(steamid.SteamId64.ToString(), adminInfo, reason, time, 2); + SimpleAdminApi?.OnPlayerPenaltiedAddedEvent(steamid, adminInfo, PenaltyType.Silence, reason, time, penaltyId); + }); + + Helper.SendDiscordPenaltyMessage(caller, steamid.SteamId64.ToString(), reason, time, PenaltyType.Silence, _localizer); + } + } [RequiresPermissions("@css/chat")] [CommandHelper(minArgs: 1, usage: " [reason]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)] diff --git a/CS2-SimpleAdmin/Events.cs b/CS2-SimpleAdmin/Events.cs index fb9efd5..bc710c9 100644 --- a/CS2-SimpleAdmin/Events.cs +++ b/CS2-SimpleAdmin/Events.cs @@ -12,6 +12,7 @@ using System.Text; using CounterStrikeSharp.API.Core.Translations; using CounterStrikeSharp.API.Modules.Admin; using CounterStrikeSharp.API.Modules.UserMessages; +using CounterStrikeSharp.API.ValveConstants.Protobuf; namespace CS2_SimpleAdmin; @@ -62,6 +63,9 @@ public partial class CS2_SimpleAdmin [GameEventHandler(HookMode.Pre)] public HookResult OnClientDisconnect(EventPlayerDisconnect @event, GameEventInfo info) { + if (@event.Reason is 149 or 6) + info.DontBroadcast = true; + var player = @event.Userid; #if DEBUG @@ -69,9 +73,7 @@ public partial class CS2_SimpleAdmin #endif if (player == null || !player.IsValid || player.IsBot) - { return HookResult.Continue; - } #if DEBUG Logger.LogCritical("[OnClientDisconnect] After Check"); @@ -103,12 +105,7 @@ public partial class CS2_SimpleAdmin GravityPlayers.Remove(player); if (player.UserId.HasValue) - { - if (@event.Reason == 149) - info.DontBroadcast = true; - PlayersInfo.TryRemove(player.UserId.Value, out _); - } var authorizedSteamId = player.AuthorizedSteamID; if (authorizedSteamId == null || !PermissionManager.AdminCache.TryGetValue(authorizedSteamId, @@ -132,16 +129,27 @@ public partial class CS2_SimpleAdmin #if DEBUG Logger.LogCritical("[OnClientConnect]"); #endif + if (!CS2_SimpleAdmin.BannedPlayers.Contains(ipaddress.Split(":")[0])) + return; - Server.NextFrame(() => + Server.NextFrame((() => { var player = Utilities.GetPlayerFromSlot(playerslot); - if (player == null || !player.IsValid || player.IsBot) return; + + Helper.KickPlayer(player, NetworkDisconnectionReason.NETWORK_DISCONNECT_REJECT_BANNED); + })); - new PlayerManager().LoadPlayerData(player); - }); + // Server.NextFrame(() => + // { + // var player = Utilities.GetPlayerFromSlot(playerslot); + // + // if (player == null || !player.IsValid || player.IsBot) + // return; + // + // new PlayerManager().LoadPlayerData(player); + // }); } [GameEventHandler] @@ -156,11 +164,11 @@ public partial class CS2_SimpleAdmin if (player == null || !player.IsValid || player.IsBot) return HookResult.Continue; - if (player.UserId.HasValue && PlayersInfo.TryGetValue(player.UserId.Value, out PlayerInfo? value) && -value.WaitingForKick) - return HookResult.Continue; +// if (player.UserId.HasValue && PlayersInfo.TryGetValue(player.UserId.Value, out PlayerInfo? value) && +// value.WaitingForKick) +// return HookResult.Continue; - new PlayerManager().LoadPlayerData(player, true); + new PlayerManager().LoadPlayerData(player); return HookResult.Continue; } @@ -209,6 +217,7 @@ value.WaitingForKick) if (!PlayerPenaltyManager.IsPenalized(author.Slot, PenaltyType.Gag, out DateTime? endDateTime) && !PlayerPenaltyManager.IsPenalized(author.Slot, PenaltyType.Silence, out endDateTime)) return HookResult.Continue; + if (_localizer != null && endDateTime is not null) author.SendLocalizedMessage(_localizer, "sa_player_penalty_chat_active", endDateTime.Value.ToString("g", author.GetLanguage())); return HookResult.Stop; diff --git a/CS2-SimpleAdmin/Helper.cs b/CS2-SimpleAdmin/Helper.cs index aa8c1e1..619eb29 100644 --- a/CS2-SimpleAdmin/Helper.cs +++ b/CS2-SimpleAdmin/Helper.cs @@ -409,8 +409,19 @@ internal static class Helper // _ => arg // }; // } + var validPlayers = GetValidPlayers().Where(c => c is { IsValid: true, IsBot: false }); - foreach (var controller in GetValidPlayers().Where(c => c is { IsValid: true, IsBot: false })) + if (!validPlayers.Any()) + return; + + if (CS2_SimpleAdmin.Instance.Config.OtherSettings.ShowActivityType == 3) + { + validPlayers = validPlayers.Where(c => + AdminManager.PlayerHasPermissions(new SteamID(c.SteamID), "@css/kick") || + AdminManager.PlayerHasPermissions(new SteamID(c.SteamID), "@css/ban")); + } + + foreach (var controller in validPlayers.ToList()) { var currentMessageArgs = (string[])formattedMessageArgs.Clone(); @@ -421,8 +432,7 @@ internal static class Helper currentMessageArgs[i] = CS2_SimpleAdmin.Instance.Config.OtherSettings.ShowActivityType switch { 1 => arg.Replace("CALLER", AdminManager.PlayerHasPermissions(new SteamID(controller.SteamID), "@css/kick") || AdminManager.PlayerHasPermissions(new SteamID(controller.SteamID), "@css/ban") ? callerName : CS2_SimpleAdmin._localizer["sa_admin"]), - 2 => arg.Replace("CALLER", callerName ?? CS2_SimpleAdmin._localizer["sa_console"]), - _ => arg + _ => arg.Replace("CALLER", callerName ?? CS2_SimpleAdmin._localizer["sa_console"]), }; } @@ -452,7 +462,6 @@ internal static class Helper formattedMessageArgs[i] = CS2_SimpleAdmin.Instance.Config.OtherSettings.ShowActivityType switch { 1 => arg.Replace("CALLER", CS2_SimpleAdmin._localizer["sa_admin"]), - 2 => arg.Replace("CALLER", callerName ?? CS2_SimpleAdmin._localizer["sa_console"]), _ => arg }; } diff --git a/CS2-SimpleAdmin/Managers/PermissionManager.cs b/CS2-SimpleAdmin/Managers/PermissionManager.cs index 8019d99..65bfaea 100644 --- a/CS2-SimpleAdmin/Managers/PermissionManager.cs +++ b/CS2-SimpleAdmin/Managers/PermissionManager.cs @@ -446,9 +446,20 @@ public class PermissionManager(Database.Database? database) { if (flag.StartsWith($"#")) { - const string sql = "SELECT id FROM `sa_groups` WHERE name = @groupName"; - var groupId = await connection.QuerySingleOrDefaultAsync(sql, new { groupName = flag }); + // const string sql = "SELECT id FROM `sa_groups` WHERE name = @groupName"; + // var groupId = await connection.QuerySingleOrDefaultAsync(sql, new { groupName = flag }); + const string sql = """ + SELECT sgs.group_id + FROM sa_groups_servers sgs + JOIN sa_groups sg ON sgs.group_id = sg.id + WHERE sg.name = @groupName + ORDER BY (sgs.server_id = @serverId) DESC, sgs.server_id ASC + LIMIT 1 + """; + + var groupId = await connection.QuerySingleOrDefaultAsync(sql, new { groupName = flag, CS2_SimpleAdmin.ServerId }); + if (groupId != null) { const string updateAdminGroup = "UPDATE `sa_admins` SET group_id = @groupId WHERE id = @adminId"; diff --git a/CS2-SimpleAdmin/Managers/PlayerManager.cs b/CS2-SimpleAdmin/Managers/PlayerManager.cs index 0812cc1..7ad5191 100644 --- a/CS2-SimpleAdmin/Managers/PlayerManager.cs +++ b/CS2-SimpleAdmin/Managers/PlayerManager.cs @@ -124,14 +124,14 @@ public class PlayerManager var victim = Utilities.GetPlayerFromUserid(userId); if (victim == null || !victim.UserId.HasValue) return; - + Helper.KickPlayer(userId, NetworkDisconnectionReason.NETWORK_DISCONNECT_REJECT_BANNED); }); return; } - if (fullConnect) + if (fullConnect || !fullConnect) // Temp skip { var warns = await CS2_SimpleAdmin.Instance.WarnManager.GetPlayerWarns(CS2_SimpleAdmin.PlayersInfo[userId], false); var (totalMutes, totalGags, totalSilences) = diff --git a/CS2-SimpleAdmin/VERSION b/CS2-SimpleAdmin/VERSION index cbbfa5a..3ebe98c 100644 --- a/CS2-SimpleAdmin/VERSION +++ b/CS2-SimpleAdmin/VERSION @@ -1 +1 @@ -1.7.2c \ No newline at end of file +1.7.3a \ No newline at end of file diff --git a/CS2-SimpleAdminApi/CS2-SimpleAdminApi.csproj b/CS2-SimpleAdminApi/CS2-SimpleAdminApi.csproj index cb68664..228359e 100644 --- a/CS2-SimpleAdminApi/CS2-SimpleAdminApi.csproj +++ b/CS2-SimpleAdminApi/CS2-SimpleAdminApi.csproj @@ -8,7 +8,7 @@ - + diff --git a/CS2-SimpleAdminApi/ICS2-SimpleAdminApi.cs b/CS2-SimpleAdminApi/ICS2-SimpleAdminApi.cs index 6447f90..ef6ba97 100644 --- a/CS2-SimpleAdminApi/ICS2-SimpleAdminApi.cs +++ b/CS2-SimpleAdminApi/ICS2-SimpleAdminApi.cs @@ -21,6 +21,7 @@ public interface ICS2_SimpleAdminApi public event Action? OnPlayerPenaltiedAdded; public void IssuePenalty(CCSPlayerController player, CCSPlayerController? admin, PenaltyType penaltyType, string reason, int duration = -1); + public void IssuePenalty(SteamID steamid, CCSPlayerController? admin, PenaltyType penaltyType, string reason, int duration = -1); public void LogCommand(CCSPlayerController? caller, string command); public void LogCommand(CCSPlayerController? caller, CommandInfo command); diff --git a/Modules/CS2-SimpleAdmin_CleanModule/CS2-SimpleAdminApi.dll b/Modules/CS2-SimpleAdmin_CleanModule/CS2-SimpleAdminApi.dll index 2e65ca9..ad16a31 100644 Binary files a/Modules/CS2-SimpleAdmin_CleanModule/CS2-SimpleAdminApi.dll and b/Modules/CS2-SimpleAdmin_CleanModule/CS2-SimpleAdminApi.dll differ diff --git a/Modules/CS2-SimpleAdmin_ExampleModule/CS2-SimpleAdminApi.dll b/Modules/CS2-SimpleAdmin_ExampleModule/CS2-SimpleAdminApi.dll index 2e65ca9..ad16a31 100644 Binary files a/Modules/CS2-SimpleAdmin_ExampleModule/CS2-SimpleAdminApi.dll and b/Modules/CS2-SimpleAdmin_ExampleModule/CS2-SimpleAdminApi.dll differ diff --git a/Modules/CS2-SimpleAdmin_ExampleModule/CS2-SimpleAdmin_ExampleModule.cs b/Modules/CS2-SimpleAdmin_ExampleModule/CS2-SimpleAdmin_ExampleModule.cs index f69ee39..58ca217 100644 --- a/Modules/CS2-SimpleAdmin_ExampleModule/CS2-SimpleAdmin_ExampleModule.cs +++ b/Modules/CS2-SimpleAdmin_ExampleModule/CS2-SimpleAdmin_ExampleModule.cs @@ -12,7 +12,7 @@ namespace CS2_SimpleAdmin_ExampleModule; public class CS2_SimpleAdmin_ExampleModule: BasePlugin { public override string ModuleName => "[CS2-SimpleAdmin] Example module"; - public override string ModuleVersion => "v1.0.0"; + public override string ModuleVersion => "v1.0.1"; public override string ModuleAuthor => "daffyy"; private int? _serverId; @@ -68,6 +68,13 @@ public class CS2_SimpleAdmin_ExampleModule: BasePlugin commandInfo.ReplyToCommand($"Your total mutes: {playerInfo?.TotalMutes}"); commandInfo.ReplyToCommand($"Your total silences: {playerInfo?.SteamId}"); } + + [ConsoleCommand("css_testaddban")] + [CommandHelper(whoCanExecute: CommandUsage.SERVER_ONLY)] + public void OnAddBanCommand(CCSPlayerController? caller, CommandInfo commandInfo) + { + _sharedApi?.IssuePenalty(new SteamID(76561197960287930), null, PenaltyType.Ban, "My super reason", 10); + } private void OnPlayerPenaltied(PlayerInfo player, PlayerInfo? admin, PenaltyType penaltyType, string reason, int duration, int? penaltyId, int? serverId)