AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Permission System question (https://forums.alliedmods.net/showthread.php?t=339994)

xerox8521 10-16-2022 15:56

Permission System question
 
Hi,

so I wanted to combine SM Groups with Forum Groups however I seem to not understand something or missing something obvious.
When I create the admin entry and bind it to the steam id I still do not have access.
According to GetAdminFlags used Access_Real and Effective I do have permissions but if I try to access the admin menu I do not have permission and sm_who also shows I have no permissions either.

I do use return Plugin_Handled for OnClientPreAdminCheck.

Debug Output when I first join the server after starting it:

PHP Code:

FindAdminByIdentity: -INVALID_ADMIN_ID: -1
CreateAdmin
41
Bound to identity
STEAM_0:1:22334304
AdminID
41
GetAdminGroupCount
0
AdminFlags Effective
0
AdminFlags Real
0
GetAdmGroupAddFlags
16386
---------------------------------------
Inherited root admin group
AdminFlags Effective
16386
AdminFlags Real
16386
GetAdmGroupAddFlags
16386 

and this after rejoining:
PHP Code:

FindAdminByIdentity41 INVALID_ADMIN_ID: -1
GetAdminGroupCount
1
Group
Root
AdminFlags Effective
16386
AdminFlags Real
16386
GetAdmGroupAddFlags
16386
---------------------------------------
AdminFlags Effective16386
AdminFlags Real
16386
GetAdmGroupAddFlags
16386 

Plugin Code:

PHP Code:

void AssignAdminByGroupID(int clientint groupID)
{
    
AdminId admin INVALID_ADMIN_ID;
    
admin FindAdminByIdentity("steam"pInfo[client].steamID32);
    
PrintToServer("FindAdminByIdentity: %d | INVALID_ADMIN_ID: %d"adminINVALID_ADMIN_ID);
    if(
admin == INVALID_ADMIN_ID)
    {
        
admin CreateAdmin(pInfo[client].username);
        
PrintToServer("CreateAdmin: %d"admin);
        if(!
admin.BindIdentity("steam"pInfo[client].steamID32))
        {
            
RemoveAdmin(admin);
            
PrintToConsole(client"There was an error assigning your admin permissions");
            
LogError("Failed to bind admin identity for %N (%s)"clientpInfo[client].steamID32);
        }
        else
        {
            
PrintToServer("Bound to identity: %s"pInfo[client].steamID32);
        }
        
pInfo[client].bLoaded true;
        
PrintToServer("AdminID: %d"admin);
        
char name[PLATFORM_MAX_PATH];

        
int count GetAdminGroupCount(admin);
        
PrintToServer("GetAdminGroupCount: %d"count);
        for(
int i 0icounti++)
        {
            
GetAdminGroup(admininamesizeof(name));
            
PrintToServer("Group: %s"name);
        }
        
AdminFlag flags[26];
        
        switch(
groupID)
        {
            case 
USERGROUP_MANAGEMENT:
            {
                
PrintToServer("AdminFlags Effective: %d"GetAdminFlags(adminAccess_Effective));
                
PrintToServer("AdminFlags Real: %d"GetAdminFlags(adminAccess_Real));
                
PrintToServer("GetAdmGroupAddFlags: %d"GetAdmGroupAddFlags(admGroupRoot));
                
PrintToServer("---------------------------------------");
                if(
admin.InheritGroup(admGroupRoot))
                {
                    
PrintToServer("Inherited root admin group");
                }
                
int num_flags FlagBitsToArray(GetAdmGroupAddFlags(admGroupRoot), flagssizeof(flags));

                for(
int i 0<num_flagsi++ )
                {
                    
admin.SetFlag(flags[i], true);
                }
                
PrintToServer("AdminFlags Effective: %d"GetAdminFlags(adminAccess_Effective));
                
PrintToServer("AdminFlags Real: %d"GetAdminFlags(adminAccess_Real));
                
PrintToServer("GetAdmGroupAddFlags: %d"GetAdmGroupAddFlags(admGroupRoot));
            }
        }
    }
    else
    {
        
char name[PLATFORM_MAX_PATH];
        if(
admin.BindIdentity("steam"pInfo[client].steamID32))
        {
            
PrintToServer("Bound to SteamID: %s"pInfo[client].steamID32);
        }
        
int count GetAdminGroupCount(admin);
        
PrintToServer("GetAdminGroupCount: %d"count);
        for(
int i 0icounti++)
        {
            
GetAdminGroup(admininamesizeof(name));
            
PrintToServer("Group: %s"name);
        }
        
AdminFlag flags[26];
        
        switch(
groupID)
        {
            case 
USERGROUP_MANAGEMENT:
            {
                
PrintToServer("AdminFlags Effective: %d"GetAdminFlags(adminAccess_Effective));
                
PrintToServer("AdminFlags Real: %d"GetAdminFlags(adminAccess_Real));
                
PrintToServer("GetAdmGroupAddFlags: %d"GetAdmGroupAddFlags(admGroupRoot));
                
PrintToServer("---------------------------------------");
                if(
admin.InheritGroup(admGroupRoot))
                {
                    
PrintToServer("Inherited root admin group");
                }
                
int num_flags FlagBitsToArray(GetAdmGroupAddFlags(admGroupRoot), flagssizeof(flags));

                for(
int i 0<num_flagsi++ )
                {
                    
admin.SetFlag(flags[i], true);
                }
                
PrintToServer("AdminFlags Effective: %d"GetAdminFlags(adminAccess_Effective));
                
PrintToServer("AdminFlags Real: %d"GetAdminFlags(adminAccess_Real));
                
PrintToServer("GetAdmGroupAddFlags: %d"GetAdmGroupAddFlags(admGroupRoot));
            }
        }
    }
    
NotifyPostAdminCheck(client);



Bacardi 10-17-2022 11:55

Re: Permission System question
 
...could you just, grant custom admins after OnClientPostAdminCheck ?
- Let SourceMod do own admins separatelly.
- You do own admins afterwards.


All times are GMT -4. The time now is 18:52.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.