zio fork 1.8.2b-zio16: backport unban, rename and css_history from upstream 1.9.0
From upstream 530f603: - css_unban updates the ban cache at once (and clears the engine banid with UnlockedCommands) instead of waiting up to a minute for the cache refresh. - css_prename is saved in sa_renames (migration 017) and re-applied on connect and name change, so it survives restarts. css_rename from a hidden admin renames again. - New css_history command and Players > History menu entry. Commands missing from an existing Commands.json are registered under their default name. - Migrations are copied with a glob, so 017 reaches the build output. Upstream's admin-loading changes, css_say change and css_penalties fix are left out.
This commit is contained in:
parent
8bec658db4
commit
71d51d7b92
35 changed files with 539 additions and 143 deletions
|
|
@ -543,18 +543,31 @@ public partial class CS2_SimpleAdmin
|
|||
[GameEventHandler]
|
||||
public HookResult OnPlayerInfo(EventPlayerInfo @event, GameEventInfo _)
|
||||
{
|
||||
var player = @event.Userid;
|
||||
|
||||
if (player is null || !player.IsValid || player.IsBot)
|
||||
return HookResult.Continue;
|
||||
|
||||
if (!RenamedPlayers.TryGetValue(player.SteamID, out var name)) return HookResult.Continue;
|
||||
|
||||
if (player.PlayerName.Equals(name))
|
||||
return HookResult.Continue;
|
||||
|
||||
player.Rename(name);
|
||||
|
||||
EnforceRename(@event.Userid);
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
[GameEventHandler]
|
||||
public HookResult OnPlayerChangename(EventPlayerChangename @event, GameEventInfo _)
|
||||
{
|
||||
EnforceRename(@event.Userid);
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Re-applies a permanent rename. Checked after a short delay because the engine may not
|
||||
/// have written the client's new name yet when the event fires, and Rename itself
|
||||
/// takes 0.4s to settle (it briefly writes the name with a trailing space).
|
||||
/// </summary>
|
||||
private void EnforceRename(CCSPlayerController? player)
|
||||
{
|
||||
if (player is null || !player.IsValid || player.IsBot) return;
|
||||
if (!RenamedPlayers.TryGetValue(player.SteamID, out var name)) return;
|
||||
|
||||
AddTimer(0.5f, () =>
|
||||
{
|
||||
if (player.IsValid && !player.PlayerName.Equals(name))
|
||||
player.Rename(name);
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue