Raised This Month: $51 Target: $400
 12% 

register_concomd with multiple access levels


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DPT
Member
Join Date: Jun 2011
Old 02-11-2012 , 23:37   register_concomd with multiple access levels
Reply With Quote #1

Hello again..

I have a question.. Can cmd_access check a command against multiple access levels? If yes, whats the sytanx exactly?

I've tried the following but it didnt work
register_concmd("amx_test","cmdTest",ADMIN_BA N & ADMIN_LEVEL_H & ADMIN_LEVEL_G)

In some other post, I saw that I should try doing the following

register_concmd("amx_test","cmdTest",ADMIN_BA N|ADMIN_LEVEL_H|ADMIN_LEVEL_G)

but again it didnt work..

Any help would be appreciated..
DPT is offline
naXe
BANNED
Join Date: May 2009
Location: Poland/Kwidzyn
Old 02-11-2012 , 23:44   Re: register_concomd with multiple access levels
Reply With Quote #2

&& ?
naXe is offline
Send a message via AIM to naXe
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-12-2012 , 02:46   Re: register_concomd with multiple access levels
Reply With Quote #3

Quote:
Originally Posted by DPT View Post
PHP Code:
register_concmd("amx_test","cmdTest",ADMIN_BAN ADMIN_LEVEL_H ADMIN_LEVEL_G
This won't let anyone access anything.

Quote:
Originally Posted by DPT View Post
PHP Code:
register_concmd("amx_test","cmdTest",ADMIN_BAN|ADMIN_LEVEL_H|ADMIN_LEVEL_G
This will allow anyone with ADMIN_BAN or ADMIN_LEVEL_H or ADMIN_LEVEL_G access the command.

If you want to require all of the flags to access the command you can use this version of cmd_access() with the second version of register_concmd() that you posted.

PHP Code:
stock cmd_access_require_all(idlevelcidnumbool:accesssilent false
{
    new 
has_access 0;
    if ( 
id==(is_dedicated_server()?0:1) ) 
    {
        
has_access 1;
    }
    else if ( 
level==ADMIN_ADMIN )
    {
        if ( 
is_user_admin(id) )
        {
            
has_access 1;
        }
    }
    else if ( 
get_user_flags(id) & level == level )
    {
        
has_access 1;
    }
    else if (
level == ADMIN_ALL
    {
        
has_access 1;
    }

    if ( 
has_access==
    {
        if (!
accesssilent)
        {
#if defined AMXMOD_BCOMPAT
            
console_print(idSIMPLE_T("You have no access to that command."));
#else
            
console_print(id,"%L",id,"NO_ACC_COM");
#endif
        
}
        return 
0;
    }
    if (
read_argc() < num
    {
        new 
hcmd[32], hinfo[128], hflag;
        
get_concmd(cid,hcmd,31,hflag,hinfo,127,level);
#if defined AMXMOD_BCOMPAT
        
console_print(idSIMPLE_T("Usage:  %s %s"), hcmdSIMPLE_T(hinfo));
#else
        
console_print(id,"%L:  %s %s",id,"USAGE",hcmd,hinfo);
#endif
        
return 0;
    }
    
    return 
1;

__________________
fysiks is offline
DPT
Member
Join Date: Jun 2011
Old 02-12-2012 , 20:09   Re: register_concomd with multiple access levels
Reply With Quote #4

fysiks, I have tried:

PHP Code:
register_concmd("amx_test","cmdTest",ADMIN_BAN|ADMIN_LEVEL_H|ADMIN_LEVEL_G
Users with the ADMIN_BAN flag and ADMIN_LEVEL_H were able to access the command. However, users with ADMIN_LEVEL_G were not able to access it. Thats strange.. I tried swapping ADMIN_LEVEL_H with ADMIN_LEVEL_G and still the same results.. users with the ADMIN_LEVEL_G flag were not able to access the command.

To test even further, I tried this:

PHP Code:
register_concmd("amx_test","cmdknifes_only",ADMIN_BAN|ADMIN_LEVEL_G
and guess what, users with ADMIN_LEVEL_H were able to access the command although i removed ADMIN_LEVEL_H this time.. I think there's something wrong with the | between the access levels?

Any other alternative? How can i use get_user_flags to properly check if a user has either ADMIN_BAN OR ADMIN_LEVEL_H OR ADMIN_LEVEL_G flag using an if statement?

Can you please help?

Last edited by DPT; 02-19-2012 at 15:07.
DPT is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-12-2012 , 20:50   Re: register_concomd with multiple access levels
Reply With Quote #5

Some of your experiences sound like you didn't update the .amxx file and restarting before trying again.

Any of the ADMIN_ constants can be put together with the | and it will work if the person has at least one of them.

What were the flags listed in users.ini of those who tried and it didn't work?
__________________
fysiks is offline
DPT
Member
Join Date: Jun 2011
Old 02-12-2012 , 20:58   Re: register_concomd with multiple access levels
Reply With Quote #6

Fysiks, I did.. Every time I update my plugin, I restart the server to make sure its updated.. for the users who have the ADMIN_LEVEL_G flag, the flags "fs" are in users.ini ... and for ADMIN_LEVEL_H, the flags in users.ini are "acfit"
DPT is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 02-12-2012 , 21:32   Re: register_concomd with multiple access levels
Reply With Quote #7

Make sure your cmdaccess.ini (configs folder) is updated accordingly.

IIRC, once you register a command (and it is placed in the cmdaccess.ini) and then change the access flags, the cmdaccess.ini is not updated with the new flags; it still contains the old flags from the original register.

Last edited by Emp`; 02-12-2012 at 21:32.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
DPT
Member
Join Date: Jun 2011
Old 02-12-2012 , 21:44   Re: register_concomd with multiple access levels
Reply With Quote #8

Emp, to be honest, I did not understand you clearly.. Is there any easier method of checking if the user has either ADMIN_BAN or ADMIN_LEVEL_H or ADMIN_LEVEL_G.. Can't we do it using the get_user_flags function? How would the if statement look like?

This if statement didn't really work:

PHP Code:
new uflags get_user_flags(id)
if (
uflags != ADMIN_BAN uflags != ADMIN_LEVEL_G uflags != ADMIN_LEVEL_H)
return 
PLUGIN_HANDLED 
DPT is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-12-2012 , 23:29   Re: register_concomd with multiple access levels
Reply With Quote #9

Quote:
Originally Posted by DPT View Post
Emp, to be honest, I did not understand you clearly..
He said you need to look in /addons/amxmodx/configs/cmdaccess.ini. Find your command and change the flags to what you want in that file. In your case it would be "dst".


Quote:
Originally Posted by DPT View Post
Is there any easier method of checking if the user has either ADMIN_BAN or ADMIN_LEVEL_H or ADMIN_LEVEL_G.. Can't we do it using the get_user_flags function? How would the if statement look like?
cmd_access() should work fine once you solve your issue. There is nothing wrong with cmd_access().

Quote:
Originally Posted by DPT View Post
This if statement didn't really work:

PHP Code:
new uflags get_user_flags(id)
if (
uflags != ADMIN_BAN uflags != ADMIN_LEVEL_G uflags != ADMIN_LEVEL_H)
return 
PLUGIN_HANDLED 
FYI, nothing in that if statement conditional is correct. I recommend that you learn about logical and bitwise operators and how they differ. You will never want to use logical operators with ADMIN_ constants.
__________________
fysiks is offline
DPT
Member
Join Date: Jun 2011
Old 02-12-2012 , 23:42   Re: register_concomd with multiple access levels
Reply With Quote #10

Alright I did it.. I added the flags to cmdaccess.ini.. the line looks like that now

"test_plugin" "dgh" ; test.amxx

I saved it, restarted the server, and tried to access the command. However, I still get a "you have no access to that command"

Is there anything else im missing?
DPT 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 08:30.


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