Raised This Month: $ Target: $400
 0% 

Register_concmd ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
akcaliberg
Senior Member
Join Date: Nov 2011
Location: Istanbul
Old 06-15-2012 , 18:22   Register_concmd ?
Reply With Quote #1

can I use this native like that ?

PHP Code:
register_concmd("amx_example","cmdExample",ADMIN_BAN && ADMIN_IMMUNITY
Only an admin which have that two flags (d and a), can use this command.
akcaliberg is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 06-15-2012 , 18:45   Re: Register_concmd ?
Reply With Quote #2

I dont know if it is possible but if it is, should be:
PHP Code:
register_concmd("amx_example","cmdExample",ADMIN_BAN ADMIN_IMMUNITY
Because that consts are bitsums.
__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-15-2012 , 19:33   Re: Register_concmd ?
Reply With Quote #3

Quote:
Originally Posted by Neeeeeeeeeel.- View Post
I dont know if it is possible but if it is, should be:
PHP Code:
register_concmd("amx_example","cmdExample",ADMIN_BAN ADMIN_IMMUNITY
Because that consts are bitsums.
That is not correct. You need to use bitwise OR not AND.

PHP Code:
// plugin_init()
    
register_concmd("amx_example","cmdExample",ADMIN_BAN ADMIN_IMMUNITY)
// ...

public cmdExample(idlevelcid)
{
    if( (
get_user_flags(id) & level) != level )
    {
        
// User does NOT have both flags
        
return PLUGIN_HANDLED
    
}
    
    
// User has both flags

__________________

Last edited by fysiks; 06-15-2012 at 19:36.
fysiks is offline
akcaliberg
Senior Member
Join Date: Nov 2011
Location: Istanbul
Old 06-16-2012 , 07:32   Re: Register_concmd ?
Reply With Quote #4

Thanks but why not AND, User must has that two flags.

For example:

User1 = abcdefghijklmnopqrstu = This user has both flags ( a and d ) [This user can use that command.
User2 = bcdefghijklmnopqrstu = This user has not both flags ( has d flag but hasn't a flag) [This user can't use that command]
User3 = abcefghijklmnopqrstu = This user has not both flags ( has a flag but hasn't d flag) [This user cant use that command too.]

So Why not AND ?

When you use OR it must be a flag or d flag. Doesn't matter. If it has a flag, it can use or if it has d flag it can use too. Isn't it ? I don't understand
akcaliberg is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-16-2012 , 12:26   Re: Register_concmd ?
Reply With Quote #5

Quote:
Originally Posted by akcaliberg View Post
Thanks but why not AND, User must has that two flags.

For example:

User1 = abcdefghijklmnopqrstu = This user has both flags ( a and d ) [This user can use that command.
User2 = bcdefghijklmnopqrstu = This user has not both flags ( has d flag but hasn't a flag) [This user can't use that command]
User3 = abcefghijklmnopqrstu = This user has not both flags ( has a flag but hasn't d flag) [This user cant use that command too.]

So Why not AND ?

When you use OR it must be a flag or d flag. Doesn't matter. If it has a flag, it can use or if it has d flag it can use too. Isn't it ? I don't understand
It's because you don't understand how bitwise operations work. Google for bitwise operators and how they work. I even think there is a tutorial by Bugsy in the tutorials forum.
__________________
fysiks 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 06:07.


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