zio fork 1.8.2b-zio5: staff chat shows rank
Some checks are pending
Build and Publish / build (push) Waiting to run
Build and Publish / publish (push) Blocked by required conditions

@ in team chat and css_asay read ">[STAFF][RANK] name: message", and @ in all chat and a
player's css_say read ">[RANK] name: message", with the rank from the sender's highest #rank/...
group (O, SA, A, TA, M, TM, H). Staff in no rank group get ">[STAFF] name" and "> name". A
non-staff player's @ team chat reads ">[PLAYER] name: message". Console's messages are unchanged.
The lines are new en.json keys: sa_staffchat_template, sa_staffsay_template, their _norank
variants and sa_staffchat_template_player.
This commit is contained in:
Astra 2026-09-28 18:01:44 +01:00
parent bc6e32892d
commit 3c9f65e121
6 changed files with 69 additions and 7 deletions

View file

@ -29,13 +29,23 @@ public partial class CS2_SimpleAdmin
foreach (var player in Helper.GetValidPlayers()
.Where(p => AdminManager.PlayerHasPermissions(new SteamID(p.SteamID), "@css/chat")))
{
if (_localizer != null)
player.PrintToChat(_localizer["sa_adminchat_template_admin",
caller == null ? _localizer?["sa_console"] ?? "Console" : caller.PlayerName,
utf8String]);
if (_localizer == null) continue;
// zio: players get ">[STAFF][RANK] name: message", like @ in team chat.
player.PrintToChat(caller == null
? _localizer["sa_adminchat_template_admin", _localizer["sa_console"], utf8String]
: StaffChatMessage(caller, utf8String.Trim()));
}
}
// zio: staff chat line, ">[STAFF][RANK] name: message" ("[RANK]" left out without a rank group).
private static string StaffChatMessage(CCSPlayerController sender, string message)
{
var rank = Helper.GetStaffRankTag(sender);
return rank == null
? _localizer!["sa_staffchat_template_norank", sender.PlayerName, message]
: _localizer!["sa_staffchat_template", rank, sender.PlayerName, message];
}
/// <summary>
/// Sends a custom chat message to all players with color tags processed.
/// </summary>
@ -73,6 +83,20 @@ public partial class CS2_SimpleAdmin
var utf8String = Encoding.UTF8.GetString(utf8BytesString);
Helper.LogCommand(caller, command);
// zio: from a player (including @ in all chat), ">[RANK] name: message" with no [SA] prefix.
// Console (and the web panel over RCON) keeps the plain "ADMIN:" message.
if (caller != null && _localizer != null)
{
var rank = Helper.GetStaffRankTag(caller);
var line = rank == null
? _localizer["sa_staffsay_template_norank", caller.PlayerName, utf8String.Trim()]
: _localizer["sa_staffsay_template", rank, caller.PlayerName, utf8String.Trim()];
foreach (var player in Helper.GetValidPlayers())
player.PrintToChat(line);
return;
}
foreach (var player in Helper.GetValidPlayers())
{
player.SendLocalizedMessage(_localizer,