1.0.4c-zio6: GroupVerify clan tag for verified players, upper-case rank tags

While GroupVerify has a clan tag set (css_gv_clantag or the web panel), players without a rank
tag get it on the scoreboard if they're verified, and no tag at all if they aren't. Staff keep
their rank tag either way. With no clan tag, or GroupVerify off or missing, nothing changes;
clearing it gives players their own tags back. Tags update as soon as verification or the clan
tag changes (OnVerifiedChanged, OnClanTagChanged). GroupVerifyApi is a compile-only reference
(lib/), optional at runtime.

Also (zio5, not released on its own): the scoreboard spells ranks in capitals (OWNER, S.ADMIN,
ADMIN, ...) and chat prefixes use SimpleAdmin's staff chat rank names ([Mod], [S.Admin], ...).
This commit is contained in:
Astra 2026-10-02 18:44:36 +01:00
parent 3ac24ac3fe
commit b0e67b1ee0
5 changed files with 160 additions and 22 deletions

51
VerifyLink.cs Normal file
View file

@ -0,0 +1,51 @@
using CounterStrikeSharp.API.Core;
using GroupVerifyApi;
namespace CS2_Tags;
// zio: GroupVerify's API (shared/GroupVerifyApi). Kept in its own class, and only created inside a
// try in OnAllPluginsLoaded, so CS2-Tags still loads, and tags as before, when GroupVerify isn't
// installed and its assembly can't be found.
internal sealed class VerifyLink : IDisposable
{
private readonly IGroupVerifyApi _api;
private readonly Action<CCSPlayerController> _playerChanged;
private readonly Action _tagChanged;
private VerifyLink(IGroupVerifyApi api, Action<CCSPlayerController> playerChanged, Action tagChanged)
{
_api = api;
_playerChanged = playerChanged;
_tagChanged = tagChanged;
_api.OnVerifiedChanged += OnVerifiedChanged;
_api.OnClanTagChanged += _tagChanged;
}
// The API, or null when GroupVerify isn't loaded.
public static VerifyLink? TryCreate(Action<CCSPlayerController> playerChanged, Action tagChanged)
{
IGroupVerifyApi? api;
try
{
api = IGroupVerifyApi.Capability.Get();
}
catch (KeyNotFoundException)
{
return null;
}
return api == null ? null : new VerifyLink(api, playerChanged, tagChanged);
}
// The tag verified players without a rank get, "" while none is set or GroupVerify is off.
public string ClanTag => _api.ClanTag;
public bool IsVerified(CCSPlayerController player) => _api.IsVerified(player);
private void OnVerifiedChanged(CCSPlayerController player, VerifyStatus status) => _playerChanged(player);
public void Dispose()
{
_api.OnVerifiedChanged -= OnVerifiedChanged;
_api.OnClanTagChanged -= _tagChanged;
}
}