AlliedModders

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

EDUTz 09-17-2012 06:22

Flags related
 
Hi.
I'll try to explain briefly what i try to achieve.
I have a group that have these flags for example: e, f, g
Obviously i have some other groups that have the same flags but some more flags like: e, f, g, h, i etcetera..

How can i distinguish them? Something like
if (access == efg & !h) { do smth }

Please can you give me an example how to do this ?
Thanks in advace.

jimaway 09-17-2012 07:29

Re: Flags related
 
Code:
new flags = get_user_flags(id) if (flags & (ADMIN_SLAY | ADMIN_MAP | ADMIN_CVAR) && flags ^ ADMIN_CFG) {        //do smth }

lucas_7_94 09-17-2012 09:53

Re: Flags related
 
NOT logical isn't ~ ?

jimaway 09-17-2012 10:57

Re: Flags related
 
it is, ^ is xor

flags ^ ADMIN_CFG will return 1 if ADMIN_CFG value in flags is 0 and will return 0 if its 1

lucas_7_94 09-17-2012 12:49

Re: Flags related
 
Oh , now understand , thanks you jima.

claudiuhks 09-17-2012 16:03

Re: Flags related
 
So, more exactly:

PHP Code:

new Flags 0;
Flags |= ( << 12 );
 
if( 
Flags ^ ( << 12 ) ) // RETURNS FALSE
if( Flags ^ ( << 13 ) ) // RETURNS TRUE 


EDUTz 09-17-2012 23:15

Re: Flags related
 
Code:

public client_putinserver(id) {
        new flags = get_user_flags(id)
        if (flags & (ADMIN_SLAY | ADMIN_MAP) && flags ^ ADMIN_CHAT) {
                server_cmd(...)
        }
}

Doesn't work :)
it affects "ef" and "bcefjimr" and "bcdtefhijr" and so on ...
I need to work just on "ef" flags ...

fysiks 09-17-2012 23:32

Re: Flags related
 
Code:

if( get_user_flags(id) & (ADMIN_MAP | ADMIN_SLAY) == (ADMIN_MAP | ADMIN_SLAY) )
{
        // Has only flags "e" and "f".
}


EDUTz 09-17-2012 23:56

Re: Flags related
 
that makes more sense.
Anyway, it doesn't work either. :shock:

but it works with if( get_user_flags(id) == (ADMIN_MAP | ADMIN_SLAY) )
Thanks for your help :)

fysiks 09-18-2012 19:01

Re: Flags related
 
Quote:

Originally Posted by EDUTz (Post 1801634)
that makes more sense.
Anyway, it doesn't work either. :shock:

but it works with if( get_user_flags(id) == (ADMIN_MAP | ADMIN_SLAY) )
Thanks for your help :)

It works. Just that it's different than what you ended up using. The one that I posted allows them to have other flags but must have, at the very least, both these flags.

The one you ended up using will only return true if and only if the player has only those two flags. Is that what you wanted? When you stated in your first post that you wanted to specifically exclude flag "h" it made it seem like you could have other flags but just not "h". (Granted, mine doesn't check for the absence of any particular flags)


All times are GMT -4. The time now is 08:15.

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