AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Register_concmd ? (https://forums.alliedmods.net/showthread.php?t=187628)

akcaliberg 06-15-2012 18:22

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

Neeeeeeeeeel.- 06-15-2012 18:45

Re: Register_concmd ?
 
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.

fysiks 06-15-2012 19:33

Re: Register_concmd ?
 
Quote:

Originally Posted by Neeeeeeeeeel.- (Post 1729503)
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



akcaliberg 06-16-2012 07:32

Re: Register_concmd ?
 
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

fysiks 06-16-2012 12:26

Re: Register_concmd ?
 
Quote:

Originally Posted by akcaliberg (Post 1729714)
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.


All times are GMT -4. The time now is 06:07.

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