AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Register Access Rank Problem (get_user_flags) (https://forums.alliedmods.net/showthread.php?t=209563)

Blizzard_87 02-26-2013 23:49

Register Access Rank Problem (get_user_flags)
 
this code is spose to check the users flags and then put them in the correct Rank.

PHP Code:

public client_authorized(id)
{
    
/* Register Rank Access */
    
rank1 get_user_flags(id) & ADMIN_LEVEL_B;
    
rank2 get_user_flags(id) & ADMIN_LEVEL_C;
    
rank3 get_user_flags(id) & ADMIN_LEVEL_D;
    
rank4 get_user_flags(id) & ADMIN_ALL;
    
/************************/
    
    
if(rank4 && !rank3 && !rank2 && !rank1)
    {
        
RankName[id] = PLAYER;
    }
    
    else if(
rank3 && !rank2 && !rank1)
    {
        
RankName[id] = ADMIN;
    }
    
    else if(
rank2 && rank3 && !rank1)
    {
        
RankName[id] = HADMIN;
        
g_Protected[id] = 1;
    }
    
    else if(
rank3 && rank2 && rank1)
    {
        
RankName[id] = OWNER;
        
g_Protected[id] = 1;
    }
    


but for some reason its very buggy and doesnt work...

when i have all admin flags in users.ini... it shows me as Manager(OWNER)...

when i take away all but one to have me as ADMIN...

still shows me as Manager(OWNER).

what am i doing wrong?

this is my Ranks

PHP Code:

/* Rank Names */
enum
{
    
OWNER,
    
HADMIN,
    
ADMIN,
    
PLAYER,
    
    
AUTHORIZED
};

new const 
AccessType[AUTHORIZED][]=
{
    
"Manager",
    
"Head Admin",
    
"Admin",
    
""
}; 


fysiks 02-27-2013 01:53

Re: Register Access Rank Problem (get_user_flags)
 
Your code shows that it requires all three custom levels to be "Owner" so you are doing something wrong if it still shows you as owner. Make sure you stop the server, load the new plugin, start the server, then join when testing.

Blizzard_87 02-27-2013 02:55

Re: Register Access Rank Problem (get_user_flags)
 
Quote:

Originally Posted by fysiks (Post 1902856)
Your code shows that it requires all three custom levels to be "Owner" so you are doing something wrong if it still shows you as owner. Make sure you stop the server, load the new plugin, start the server, then join when testing.

in think I got it working now after following your advise. Thanks

Unkolix 02-27-2013 05:55

Re: Register Access Rank Problem (get_user_flags)
 
Look, your code is kinda strange it self...
Checks if user has all flags but not LEVEL B, C, D? WTF? How is it possible that user have all flags but not all?
PHP Code:

if(rank4 && !rank3 && !rank2 && !rank1)

    
RankName[id] = PLAYER


I don't know... Lol. Your code is soo confusing...

Blizzard_87 02-27-2013 08:08

Re: Register Access Rank Problem (get_user_flags)
 
PHP Code:

public onlineadmins(id) {
    new 
players[32],pnumplayer;
    
get_players(players,pnum);
    
    
get_pcvar_string(TAGPREFIXcharsmax(PREFIX));
        
    new 
temp[501],name[32], count
    
    
for( new ii<pnumi++ ) {
        if(!
g_HideRank[players[i]]) {
            
player players[i]
            
count++
            
get_user_name(player,name,31)
            
formatex(temp,500,"%s %s !n(!g%s!n),!t "tempnameAccessType[RankName[player]])
        }
    }
    if(
count)
        
client_printc(id"!g[%s]!n Admins Online:!t %s!n"PREFIXtemp)
    else
        
client_printc(id"!g[%s]!n No admins online."PREFIX)
        
    return 
PLUGIN_HANDLED;


ok still not working... it shows EVERYONE as manager unless they are admin or head admin... grr.. its annoying...

what im doing wrong

Unkolix 02-27-2013 08:22

Re: Register Access Rank Problem (get_user_flags)
 
Maybe do it like this?
PHP Code:

public client_authorized(id

    
/* Register Rank Access */ 
    
rank1 get_user_flags(id) & ADMIN_LEVEL_B
    
rank2 get_user_flags(id) & ADMIN_LEVEL_C
    
rank3 get_user_flags(id) & ADMIN_LEVEL_D
    
rank4 get_user_flags(id) & ADMIN_ALL
    
/************************/ 
    
    
if(rank4//Checks if user has all flags (doesn't need to check if he has others because it is included already)
    

        
RankName[id] = OWNER//Sets it as a owner
        
g_Protected[id] = 1//Sets protection
    
}
    else if(
rank2 && rank3 && !rank1)  //Checks if user has LEVEL C, D, but not B
    

        
RankName[id] = HADMIN//Sets it as a headadmin
        
g_Protected[id] = 1//Sets protection
    
}
    else if(
rank3 && !rank2 && !rank1)  //Checks if user has LEVEL D, but not B or C
    

        
RankName[id] = ADMIN//Sets it as a admin
    

    else if(!
rank4 && !rank3 && !rank2 && !rank1//Checks if user hasn't got any levels
    

        
RankName[id] = PLAYER//Sets it as a player
    




Blizzard_87 02-27-2013 08:29

Re: Register Access Rank Problem (get_user_flags)
 
Quote:

Originally Posted by Unkolix (Post 1902967)
Maybe do it like this?
PHP Code:

public client_authorized(id

    
/* Register Rank Access */ 
    
rank1 get_user_flags(id) & ADMIN_LEVEL_B
    
rank2 get_user_flags(id) & ADMIN_LEVEL_C
    
rank3 get_user_flags(id) & ADMIN_LEVEL_D
    
rank4 get_user_flags(id) & ADMIN_ALL
    
/************************/ 
    
    
if(rank4//Checks if user has all flags (doesn't need to check if he has others because it is included already)
    

        
RankName[id] = OWNER//Sets it as a owner
        
g_Protected[id] = 1//Sets protection
    
}
    else if(
rank2 && rank3 && !rank1)  //Checks if user has LEVEL C, D, but not B
    

        
RankName[id] = HADMIN//Sets it as a headadmin
        
g_Protected[id] = 1//Sets protection
    
}
    else if(
rank3 && !rank2 && !rank1)  //Checks if user has LEVEL D, but not B or C
    

        
RankName[id] = ADMIN//Sets it as a admin
    

    else if(!
rank4 && !rank3 && !rank2 && !rank1//Checks if user hasn't got any levels
    

        
RankName[id] = PLAYER//Sets it as a player
    




i'll test this out tomorrow to late now

thanks...

got any ideas on this one tho?

PHP Code:

public onlineadmins(id) {
    new 
players[32],pnumplayer;
    
get_players(players,pnum);
    
    
get_pcvar_string(TAGPREFIXcharsmax(PREFIX));
        
    new 
temp[501],name[32], count
    
    
for( new ii<pnumi++ ) {
        if(!
g_HideRank[players[i]]) {
            
player players[i]
            
count++
            
get_user_name(player,name,31)
            
formatex(temp,500,"%s %s !n(!g%s!n),!t "tempnameAccessType[RankName[player]])
        }
    }
    if(
count)
        
client_printc(id"!g[%s]!n Admins Online:!t %s!n"PREFIXtemp)
    else
        
client_printc(id"!g[%s]!n No admins online."PREFIX)
        
    return 
PLUGIN_HANDLED;


doesnt work properly.

ConnorMcLeod 02-27-2013 13:29

Re: Register Access Rank Problem (get_user_flags)
 
2 ways :

PHP Code:

public client_authorized(id)
{
    new 
flags get_user_flags(id) & ADMIN_LEVEL_B|ADMIN_LEVEL_C|ADMIN_LEVEL_D

    
if( flags == ADMIN_LEVEL_B|ADMIN_LEVEL_C|ADMIN_LEVEL_D )
    {
        
RankName[id] = OWNER
        g_Protected
[id] = 1
    
}
    else if( 
flags == ADMIN_LEVEL_C|ADMIN_LEVEL_D )
    {
        
RankName[id] = HADMIN
        g_Protected
[id] = 1
    
}
    else if( 
flags == ADMIN_LEVEL_D )
    {
        
RankName[id] = ADMIN
        g_Protected
[id] = 0
    
}
    else
    {
        
RankName[id] = PLAYER
        g_Protected
[id] = 0
    
}
}

public 
client_authorized(id)
{
    new 
flags get_user_flags(id)

    if( 
flags == ADMIN_LEVEL_B )
    {
        
RankName[id] = OWNER
        g_Protected
[id] = 1
    
}
    else if( 
flags == ADMIN_LEVEL_C )
    {
        
RankName[id] = HADMIN
        g_Protected
[id] = 1
    
}
    else if( 
flags == ADMIN_LEVEL_D )
    {
        
RankName[id] = ADMIN
        g_Protected
[id] = 0
    
}
    else
    {
        
RankName[id] = PLAYER
        g_Protected
[id] = 0
    
}




All times are GMT -4. The time now is 21:43.

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