Raised This Month: $ Target: $400
 0% 

Register Access Rank Problem (get_user_flags)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 02-26-2013 , 23:49   Register Access Rank Problem (get_user_flags)
Reply With Quote #1

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",
    
""
}; 
Blizzard_87 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-27-2013 , 01:53   Re: Register Access Rank Problem (get_user_flags)
Reply With Quote #2

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.
__________________
fysiks is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 02-27-2013 , 02:55   Re: Register Access Rank Problem (get_user_flags)
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
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
Blizzard_87 is offline
Unkolix
Veteran Member
Join Date: Sep 2012
Old 02-27-2013 , 05:55   Re: Register Access Rank Problem (get_user_flags)
Reply With Quote #4

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...

Last edited by Unkolix; 02-27-2013 at 05:58.
Unkolix is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 02-27-2013 , 08:08   Re: Register Access Rank Problem (get_user_flags)
Reply With Quote #5

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
Blizzard_87 is offline
Unkolix
Veteran Member
Join Date: Sep 2012
Old 02-27-2013 , 08:22   Re: Register Access Rank Problem (get_user_flags)
Reply With Quote #6

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
    


Unkolix is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 02-27-2013 , 08:29   Re: Register Access Rank Problem (get_user_flags)
Reply With Quote #7

Quote:
Originally Posted by Unkolix View Post
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.
Blizzard_87 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-27-2013 , 13:29   Re: Register Access Rank Problem (get_user_flags)
Reply With Quote #8

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
    
}

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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