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

define two flags?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DeLiriuM
Senior Member
Join Date: Dec 2006
Old 11-21-2010 , 05:14   define two flags?
Reply With Quote #1

Is it possible, to define 2 (or more) flags, so that the admin can use the specific command.

For example:
#define ADMIN_LEVEL_A && ADMIN_LEVEL_B
The admin should have both "m" and "n" so that he could use +hook (for example).
__________________
DeLiriuM is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-21-2010 , 05:37   Re: define two flags?
Reply With Quote #2

PHP Code:
const FLAG_ADMIN_HOOK ADMIN_LEVEL_A ADMIN_LEVEL_B

register_clcmd
("+hook""ClCmd_HookOn"FLAG_ADMIN_HOOK)

public 
ClCmd_HookOn(idlvl)
{
    if( !
is_user_alive(id) || get_user_flags(id) & FLAG_ADMIN_HOOK != FLAG_ADMIN_HOOK )
    {
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_HANDLED

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
DeLiriuM
Senior Member
Join Date: Dec 2006
Old 09-04-2011 , 05:08   Re: define two flags?
Reply With Quote #3

Ok. What happens if I want to define 6 flags for example? Is there an easier way?


(1) Flags abcd => get access to specific command.
(2) Flag b => access to another specific command.

But (1) shouldn't have access to (2).
__________________
DeLiriuM is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 09-04-2011 , 05:21   Re: define two flags?
Reply With Quote #4

if ( get_user_flags(id) == read_flags("abcd") )
if ( get_user_flags(id) == read_flags("b") )
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 09-04-2011 , 05:23   Re: define two flags?
Reply With Quote #5

Just do it like

PHP Code:
const FLAGS ADMIN_IMMUNITY ADMIN_KICK ADMIN_BAN ADMIN_RESERVATION
const FLAG ADMIN_RESERVATION


if(get_user_flags(id) & FLAGS)
 return

if(
get_user_flags(id) & FLAG)
 
// has only b flag 
__________________
Currently busy working on a very large scale anime database project.
Backstabnoob is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-04-2011 , 06:28   Re: define two flags?
Reply With Quote #6

Backstabnoob is wrong.

PHP Code:
public plugin_init()
{
    
register_clcmd("amx_command""ClCmd_Command")
}

public 
ClCmd_Command(id)
{
    const 
ADMIN_FULLACCESS ADMIN_IMMUNITY ADMIN_RESERVATION ADMIN_KICK ADMIN_BAN
    
new iFlags get_user_flags(id)
    if( 
iFlags ADMIN_FULLACCESS == ADMIN_FULLACCESS )
    {
        
// first command code
    
}
    else if( 
iFlags ADMIN_RESERVATION )
    {
        
// second command code
    
}
    return 
PLUGIN_HANDLED

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 09-04-2011 , 06:42   Re: define two flags?
Reply With Quote #7

Can you explain why is there the equality operator? I kind of don't understand that...

Edit: what exactly is wrong with that? I thought that when a player has all of these access flags, it shall not allow him process to the next check.
__________________
Currently busy working on a very large scale anime database project.

Last edited by Backstabnoob; 09-04-2011 at 06:47.
Backstabnoob is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-04-2011 , 06:50   Re: define two flags?
Reply With Quote #8

If you don't put == it means the flag can be either ADMIN_IMMUNITY or ADMIN_RESERVATION , etc.. And not ADMIN_IMMUNITY and ADMIN_IMMUNITY, etc..
__________________
Arkshine is offline
Backstabnoob
Veteran Member
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 09-04-2011 , 06:52   Re: define two flags?
Reply With Quote #9

Thanks, looks like I made a lot of mistakes because of that
__________________
Currently busy working on a very large scale anime database project.
Backstabnoob 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 09:26.


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