Compare commits

..

2 commits

Author SHA1 Message Date
Ravid Atia
03a454b1b5
Merge pull request #296 from daffyyyy/fix/connect-penalty-counts
Fix connect penalty counts always showing 0 (1.9.1)
2026-10-16 12:49:15 +03:00
Ravid-A
c7395e5061 Fix connect penalty counts always showing 0 (1.9.1)
The admin notification on player connect always reported 0 bans, gags,
mutes and silences.

- MuteManager.GetPlayerMutes ran GetRetrieveMutesQuery (the unmute id
  lookup, which needs @pattern/@muteType) instead of GetMuteStatsQuery.
  The query threw, the catch returned (0,0,0), so mute counts were
  always 0.
- CacheManager.GetPlayerBansBySteamId read _steamIdIndex, which only
  holds ACTIVE bans. Anyone with an active ban is kicked before the
  message is sent, so the count was always 0. It now counts all of the
  player's bans in _banCache (expired/unbanned included). The connect
  message is its only caller; the ban check still uses the active index.
2026-10-16 12:47:38 +03:00
4 changed files with 7 additions and 4 deletions

View file

@ -22,7 +22,7 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
public override string ModuleName => "CS2-SimpleAdmin" + (Helper.IsDebugBuild ? " (DEBUG)" : " (RELEASE)");
public override string ModuleDescription => "Simple admin plugin for Counter-Strike 2 :)";
public override string ModuleAuthor => "daffyy";
public override string ModuleVersion => "1.9.0";
public override string ModuleVersion => "1.9.1";
public override void Load(bool hotReload)
{

View file

@ -442,7 +442,10 @@ internal class CacheManager: IDisposable
/// </summary>
/// <param name="steamId">64-bit Steam ID of the player.</param>
/// <returns>List of <see cref="BanRecord"/> objects associated with the Steam ID.</returns>
public List<BanRecord> GetPlayerBansBySteamId(ulong steamId) => _steamIdIndex.TryGetValue(steamId, out var bans) ? bans : [];
// _steamIdIndex holds only ACTIVE bans, so scan the full cache for history (expired/unbanned included).
// ponytail: O(n) over all cached bans per call; add an all-status index if this gets hot.
public List<BanRecord> GetPlayerBansBySteamId(ulong steamId) =>
_banCache.Values.Where(b => b.PlayerSteamId == steamId).ToList();
/// <summary>
/// Gets all known Steam accounts that have used the specified IP address.

View file

@ -159,7 +159,7 @@ internal class MuteManager(IDatabaseProvider? databaseProvider)
{
await using var connection = await databaseProvider.CreateConnectionAsync();
var sql = databaseProvider.GetRetrieveMutesQuery(CS2_SimpleAdmin.Instance.Config.MultiServerMode);
var sql = databaseProvider.GetMuteStatsQuery(CS2_SimpleAdmin.Instance.Config.MultiServerMode);
var result = await connection.QuerySingleAsync<(int TotalMutes, int TotalGags, int TotalSilences)>(sql, new
{
PlayerSteamID = playerInfo.SteamId.SteamId64,

View file

@ -1 +1 @@
1.9.0
1.9.1