Raised This Month: $ Target: $400
 0% 

register_concomd with multiple access levels


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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 09:51.


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