zio fork: @ staff chat while gagged, gag message with time left and reason
Some checks failed
Build and Publish / build (push) Has been cancelled
Build and Publish / publish (push) Has been cancelled

Gagged or silenced players can still send @ team chat to online staff. The chat-blocked message
now says how long the gag or silence has left, or that it's permanent, and why. Reasons are kept in
memory alongside each penalty. Adds release.sh, which ships CS2-SimpleAdmin.dll and lang/en.json.
This commit is contained in:
Astra 2026-09-27 19:07:06 +01:00
parent cf284bd121
commit 6171162ae9
10 changed files with 230 additions and 11 deletions

View file

@ -347,13 +347,15 @@ public partial class CS2_SimpleAdmin
return HookResult.Continue;
}
// zio: gagged players can still reach staff with @ in team chat, handled below.
var staffChat = command == "say_team" && info.GetArg(1).StartsWith('@');
// if (!Config.OtherSettings.UserMessageGagChatType)
// {
if (PlayerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Gag, out DateTime? endDateTime) ||
PlayerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Silence, out endDateTime))
if (!staffChat && (PlayerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Gag, out DateTime? endDateTime) ||
PlayerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Silence, out endDateTime)))
{
if (_localizer != null && endDateTime is not null)
player.SendLocalizedMessage(_localizer, "sa_player_penalty_chat_active", endDateTime.Value.ToString("g", player.GetLanguage()));
SendChatPenaltyMessage(player, endDateTime.Value);
return HookResult.Stop;
}
// }
@ -388,6 +390,36 @@ public partial class CS2_SimpleAdmin
return HookResult.Stop;
}
// zio: says how long the gag (or silence) has left and why, in place of its end date.
private void SendChatPenaltyMessage(CCSPlayerController player, DateTime endDateTime)
{
var type = PlayerPenaltyManager.IsPenalized(player.Slot, PenaltyType.Gag, out var gagEnd) && gagEnd == endDateTime
? PenaltyType.Gag
: PenaltyType.Silence;
var (remaining, reason) = PlayerPenaltyManager.GetPenaltyDetails(player.Slot, type, endDateTime);
var kind = type == PenaltyType.Gag ? "gag" : "silence";
using (new WithTemporaryCulture(player.GetLanguage()))
{
if (string.IsNullOrWhiteSpace(reason))
reason = _localizer!["sa_player_penalty_no_reason"];
if (remaining is null)
player.SendLocalizedMessage(_localizer, $"sa_player_penalty_{kind}_active_perm", reason);
else
player.SendLocalizedMessage(_localizer, $"sa_player_penalty_{kind}_active", FormatRemaining(remaining.Value), reason);
}
}
private static string FormatRemaining(TimeSpan remaining)
{
if (remaining.TotalMinutes < 1)
return "less than a minute";
var parts = new List<string>();
if (remaining.Days > 0) parts.Add($"{remaining.Days}d");
if (remaining.Hours > 0) parts.Add($"{remaining.Hours}h");
if (remaining.Minutes > 0 && remaining.Days == 0) parts.Add($"{remaining.Minutes}m");
return string.Join(" ", parts);
}
/*public HookResult OnCommandSay(CCSPlayerController? player, CommandInfo info)
{
if (player == null || !player.IsValid || player.IsBot)