Skip to content

fix: admins with no matching admin group vanish from !admins list - #35

Open
Rushaway wants to merge 1 commit into
masterfrom
fix/admin-list-missing-ungrouped-admins
Open

fix: admins with no matching admin group vanish from !admins list#35
Rushaway wants to merge 1 commit into
masterfrom
fix/admin-list-missing-ungrouped-admins

Conversation

@Rushaway

Copy link
Copy Markdown
Member

Description

Fixes #29 — admins were sometimes missing from the !admins list, especially when they were the only admin online.

Root cause

In getAdminsAndGroups(), every online admin was checked with GetAdminFlag(aid, Admin_Generic) to confirm they're an admin, then the code tried to find which of their admin groups explicitly adds Admin_Generic/Admin_Root/Admin_RCON (used purely for display grouping/coloring). If no group did — e.g. the admin has flags assigned directly with no group at all, or is only in a non-admin group like VIP — the code hit:

if (j >= iGroupCount)
{
    i++;
    continue;
}

and silently dropped the admin from the list entirely, even though they had already been confirmed as a real admin. This matches the reported symptom exactly (single admin online, no group assigned → shows as offline).

I confirmed adding the SourceBans++ SBPP_OnClientPostAdminCheck forward (as discussed in the issue) does not fix this — the bug is in the group-resolution logic itself, unrelated to cache-rebuild timing.

Fix

  • Stop skipping admins with no matching admin group — fall back to the existing default "Admin" bucket (gid = INVALID_GROUP_ID) instead of dropping them.
  • Fixed a related bug in that same fallback path: a second ungrouped admin online at the same time overwrote the first one at names[y][0] instead of being appended at the next free slot.
  • Fixed the fallback path storing the raw client index cast as AdminId instead of the real AdminId, which broke GetUsername() / GetClientNameOfAdminId() lookups for those admins; resolveAdminsAndGroups() updated accordingly (now uses GetClientOfAdminId() for the disconnected-check instead of casting the stored value back to an int).

How Has This Been Tested?

Compiled cleanly against SourceMod 1.12 includes with no warnings/errors.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

getAdminsAndGroups() skipped any admin whose Admin_Generic/Root/RCON
flag wasn't explicitly added by one of their admin groups (e.g. flags
assigned directly to the admin, or an admin only in non-admin groups
like VIP), even though GetAdminFlag(aid, Admin_Generic) already
confirmed they're a real admin. This is exactly the case reported in
#29, where some admins never show up in !admins, especially when they
are the only admin online.

Also fixes two related bugs in the same "no matching group" fallback
path: a second such admin overwrote the first one at names[y][0]
instead of being appended, and the code stored the raw client index
cast as AdminId instead of the real AdminId, which broke
GetUsername()/GetClientNameOfAdminId() lookups for that admin.

Fixes #29
Copilot AI lite review requested due to automatic review settings August 18, 2026 15:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: In-game admin list showing admins as offline / Missing from !admins

3 participants