From c7dae5864a22100a2e0521b5731c2377646e2672 Mon Sep 17 00:00:00 2001 From: Rushaway Date: Tue, 18 Aug 2026 17:30:42 +0200 Subject: [PATCH] fix: admins with no matching admin group vanish from !admins list 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 --- .../sourcemod/scripting/AdvancedAdminList.sp | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/addons/sourcemod/scripting/AdvancedAdminList.sp b/addons/sourcemod/scripting/AdvancedAdminList.sp index d749330..728966e 100644 --- a/addons/sourcemod/scripting/AdvancedAdminList.sp +++ b/addons/sourcemod/scripting/AdvancedAdminList.sp @@ -390,18 +390,20 @@ public void getAdminsAndGroups(GroupId[] groups, AdminId[][] names) GroupId gid = INVALID_GROUP_ID; while (j < iGroupCount) { - gid = GetAdminGroup(aid, j, group, sizeof(group)); - if (gid != INVALID_GROUP_ID && (GetAdmGroupAddFlag(gid, Admin_Generic) - || GetAdmGroupAddFlag(gid, Admin_Root) || GetAdmGroupAddFlag(gid, Admin_RCON))) + GroupId tempGid = GetAdminGroup(aid, j, group, sizeof(group)); + if (tempGid != INVALID_GROUP_ID && (GetAdmGroupAddFlag(tempGid, Admin_Generic) + || GetAdmGroupAddFlag(tempGid, Admin_Root) || GetAdmGroupAddFlag(tempGid, Admin_RCON))) + { + gid = tempGid; break; + } j++; } - if (j >= iGroupCount) - { - i++; - continue; - } + // No group explicitly grants the admin flags (e.g. flags assigned directly to + // the admin, or only non-admin groups like VIP): still list them under "Admin" + // instead of dropping them, since GetAdminFlag(aid, Admin_Generic) already confirmed + // they are a genuine admin. y = 0; while (groups[y] != UNDEFINED_GROUP_ID) @@ -411,10 +413,7 @@ public void getAdminsAndGroups(GroupId[] groups, AdminId[][] names) z = 0; while (names[y][z] != UNDEFINED_ADMIN_ID) z++; - if (gid == INVALID_GROUP_ID) - names[y][0] = view_as(i); - else - names[y][z] = aid; + names[y][z] = aid; break; } y++; @@ -423,10 +422,7 @@ public void getAdminsAndGroups(GroupId[] groups, AdminId[][] names) if (groups[y] == UNDEFINED_GROUP_ID) { groups[y] = gid; - if (gid == INVALID_GROUP_ID) - names[y][0] = view_as(i); - else - names[y][0] = aid; + names[y][0] = aid; } } } @@ -523,7 +519,7 @@ public void resolveAdminsAndGroups(GroupId[] groups, AdminId[][] names, char res while (names[resolvedAdminGroupsLength][y] != UNDEFINED_ADMIN_ID) { bufferAdminName = ""; - if (gid == INVALID_GROUP_ID && !GetClientName(view_as(names[resolvedAdminGroupsLength][y]), bufferName, sizeof(bufferName))) + if (gid == INVALID_GROUP_ID && !GetClientName(GetClientOfAdminId(names[resolvedAdminGroupsLength][y]), bufferName, sizeof(bufferName))) { Format(bufferName, sizeof(bufferName), "Disconnected: %d", names[resolvedAdminGroupsLength][y]); Format(name, sizeof(name), "%s", bufferName);