```diff
+ Recompiled for css 276 - this is the minimum version on which the plugin works
+ Added ability to check player penalties for admin with `@css/kick` flag - css_comms [#userid/name].
+ Added a new setting `ShowBanMenuIfNoTime` which allows you to disable the display of the menu when you don't specify a penalty time
```
This commit is contained in:
Dawid Bepierszcz
2024-10-06 13:48:42 +02:00
parent 6847da2af0
commit 2bee514e32
9 changed files with 47 additions and 21 deletions

View File

@@ -1,7 +1,6 @@
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.Entities;
using CounterStrikeSharp.API.Modules.Utils;
@@ -10,6 +9,7 @@ using CS2_SimpleAdmin.Models;
using CS2_SimpleAdminApi;
using Microsoft.Extensions.Logging;
using System.Text;
using CounterStrikeSharp.API.Modules.Admin;
namespace CS2_SimpleAdmin;
@@ -26,20 +26,20 @@ public partial class CS2_SimpleAdmin
// AddCommandListener("say_team", OnCommandTeamSay);
}
private HookResult OnCommandCallVote(CCSPlayerController? caller, CommandInfo commandinfo)
private HookResult OnCommandCallVote(CCSPlayerController? caller, CommandInfo info)
{
var voteType = commandinfo.GetArg(1).ToLower();
var voteType = info.GetArg(1).ToLower();
if (voteType != "kick")
return HookResult.Continue;
var target = int.TryParse(commandinfo.GetArg(2), out var userId)
var target = int.TryParse(info.GetArg(2), out var userId)
? Utilities.GetPlayerFromUserid(userId)
: null;
if (target == null || !target.IsValid || target.Connected != PlayerConnectedState.PlayerConnected)
return HookResult.Continue;
return !CounterStrikeSharp.API.Modules.Admin.AdminManager.CanPlayerTarget(caller, target) ? HookResult.Stop : HookResult.Continue;
return !AdminManager.CanPlayerTarget(caller, target) ? HookResult.Stop : HookResult.Continue;
}
private void OnGameServerSteamAPIActivated()
@@ -158,7 +158,7 @@ public partial class CS2_SimpleAdmin
if (player == null || !player.IsValid || player.IsBot)
return HookResult.Continue;
var command = info.GetArg(0);
var command = info.GetArg(0).ToLower();
if (!command.Contains("say"))
return HookResult.Continue;
@@ -173,11 +173,17 @@ public partial class CS2_SimpleAdmin
if (PlayerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Gag) || PlayerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Silence))
return HookResult.Stop;
if (command == "say" && info.GetArg(1).StartsWith($"@") &&
AdminManager.PlayerHasPermissions(player, "@css/chat"))
{
player.ExecuteClientCommandFromServer($"css_say {info.GetArg(1).Remove(0, 1)}");
return HookResult.Stop;
}
if (command != "say_team" || !info.GetArg(1).StartsWith($"@")) return HookResult.Continue;
StringBuilder sb = new();
if (CounterStrikeSharp.API.Modules.Admin.AdminManager.PlayerHasPermissions(player, "@css/chat"))
if (AdminManager.PlayerHasPermissions(player, "@css/chat"))
{
sb.Append(_localizer!["sa_adminchat_template_admin", player.PlayerName, info.GetArg(1).Remove(0, 1)]);
foreach (var p in Utilities.GetPlayers().Where(p => p.IsValid && p is { IsBot: false, IsHLTV: false } && CounterStrikeSharp.API.Modules.Admin.AdminManager.PlayerHasPermissions(p, "@css/chat")))