-
Notifications
You must be signed in to change notification settings - Fork 3
fix: Handle admin permissions for VIP users without admin flags #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
39204be
41fda24
03d57ba
fdac040
59befb3
9ffa9bc
51d6040
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,13 +14,17 @@ | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #define VIP_FEATURE_NAME "VIP" | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ConVar g_cvVIPGroupName; | ||||||||||||||||||||||||
| ConVar g_cvVIPGroupImmunity; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| bool g_bClientLoaded[MAXPLAYERS + 1] = { false, ... }; | ||||||||||||||||||||||||
| bool g_bSbppClientsLoaded = false; | ||||||||||||||||||||||||
| bool g_bReloadVips = false; | ||||||||||||||||||||||||
| bool g_bLibraryCCC = false; | ||||||||||||||||||||||||
| bool g_bLateLoaded = false; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // Track original immunity levels and VIP immunity status | ||||||||||||||||||||||||
| int g_iOriginalImmunity[MAXPLAYERS + 1] = { 0, ... }; | ||||||||||||||||||||||||
| bool g_bVIPImmunityApplied[MAXPLAYERS + 1] = { false, ... }; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| public Plugin myinfo = | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
|
|
@@ -30,10 +34,19 @@ public Plugin myinfo = | |||||||||||||||||||||||
| version = "3.2.3" | ||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| g_bLateLoaded = late; | ||||||||||||||||||||||||
| return APLRes_Success; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| public void OnAllPluginsLoaded() | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| if (LibraryExists("ccc")) | ||||||||||||||||||||||||
| g_bLibraryCCC = true; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if (g_bLateLoaded) | ||||||||||||||||||||||||
| ReloadVIPs(); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| public void OnLibraryAdded(const char[] name) | ||||||||||||||||||||||||
|
|
@@ -51,8 +64,6 @@ public void OnLibraryRemoved(const char[] name) | |||||||||||||||||||||||
| public void OnPluginStart() | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| LoadTranslations("common.phrases"); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| g_cvVIPGroupName = CreateConVar("sm_vip_group_name", "VIP", "Group name of vip users"); | ||||||||||||||||||||||||
| g_cvVIPGroupImmunity = CreateConVar("sm_vip_group_immunity", "5", "Immunity level of vip users", 0, true, 0.0, true, 100.0); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| RegAdminCmd("sm_reloadvips", Command_ReloadVips, ADMFLAG_BAN); | ||||||||||||||||||||||||
|
|
@@ -66,7 +77,11 @@ public void OnMapEnd() | |||||||||||||||||||||||
| g_bSbppClientsLoaded = false; | ||||||||||||||||||||||||
| g_bReloadVips = false; | ||||||||||||||||||||||||
| for (int i = 0; i <= MaxClients; i++) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| g_bClientLoaded[i] = false; | ||||||||||||||||||||||||
| g_iOriginalImmunity[i] = 0; | ||||||||||||||||||||||||
| g_bVIPImmunityApplied[i] = false; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| public Action Command_ReloadVips(int client, int args) | ||||||||||||||||||||||||
|
|
@@ -131,29 +146,39 @@ public bool OnClientConnect(int client, char[] rejectmsg, int maxlen) | |||||||||||||||||||||||
| public void OnClientDisconnect(int client) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| g_bClientLoaded[client] = false; | ||||||||||||||||||||||||
| g_iOriginalImmunity[client] = 0; | ||||||||||||||||||||||||
| g_bVIPImmunityApplied[client] = false; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| public Action OnClientPreAdminCheck(int client) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| return g_bSbppClientsLoaded && g_bClientLoaded[client] ? Plugin_Continue : Plugin_Handled; | ||||||||||||||||||||||||
| // If the client hasn't been processed yet, handle both VIP and non-VIP | ||||||||||||||||||||||||
| if (!g_bClientLoaded[client]) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| if (VIP_IsClientVIP(client)) | ||||||||||||||||||||||||
| LoadVIPClient(client); | ||||||||||||||||||||||||
| else | ||||||||||||||||||||||||
| g_bClientLoaded[client] = true; // Non-VIP clients should be marked as processed so they are not blocked | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| TryNotifyPostAdminCheck(client); | ||||||||||||||||||||||||
| return Plugin_Continue; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| return Plugin_Continue; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
| #if defined _sourcebanspp_included | ||||||||||||||||||||||||
| public bool SBPP_OnClientPreAdminCheck(AdminCachePart part) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| if (part == AdminCache_Admins) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| g_bSbppClientsLoaded = true; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| for (int client = 1; client <= MaxClients; client++) | ||||||||||||||||||||||||
| CheckLoadAdmin(client); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if (part == AdminCache_Admins) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| if (g_bReloadVips) | ||||||||||||||||||||||||
| ReloadVIPs(); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| g_bReloadVips = false; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
Comment on lines
177
to
181
|
||||||||||||||||||||||||
| if (g_bReloadVips) | |
| ReloadVIPs(); | |
| g_bReloadVips = false; | |
| } | |
| if (g_bReloadVips) | |
| { | |
| ReloadVIPs(); | |
| g_bReloadVips = false; | |
| } | |
| } |
Copilot
AI
Sep 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling TryNotifyPostAdminCheck which has an incomplete implementation. This will cause runtime issues as the function body is missing.
Copilot
AI
Sep 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function name TryNotifyPostAdminCheck is inconsistent with the usage of NotifyPostAdminCheck on line 163. These should use the same function name for consistency.
Copilot
AI
Aug 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting g_bClientLoaded[client] to false in RemoveClient function contradicts the function's purpose. This should remain true to indicate the client has been processed, or the logic needs to be reconsidered.
Rushaway marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Sep 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling TryNotifyPostAdminCheck which has an incomplete implementation. This will cause runtime issues as the function body is missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LoadVIPClient is called in OnClientPreAdminCheck which can be called multiple times. Consider adding a check to prevent redundant loading operations.