AlliedModders

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

edon1337 02-09-2017 11:15

get_user_flags
 
Hi.

How would I check :

User has FLAG_1 and FLAG_2 but not FLAG_3

Natsheh 02-09-2017 11:22

Re: get_user_flags
 
If(get_user_flag(id) & FLAG3) == FLAG3) return

If((get_user_flags(id) & (f1 | f2 | f3)) == f1 | f2)

FLAG123 MUST BE BITSUMS

Bugsy 02-09-2017 11:32

Re: get_user_flags
 
Quote:

Originally Posted by Natsheh (Post 2494119)
If(get_user_flag(id) & (FLAG1 | FLAG2 | ~FLAG3))

FLAG123 MUST BE BITSUMS

That will return true if the player has FLAG1 and/or FLAG2, but doesn't guarantee they have both. I also do not think your ~ condition would work as you expect.

Try this:
PHP Code:

if ( ( get_user_flagsid ) & ( FLAG1 FLAG2 FLAG3 ) ) == ( FLAG1 FLAG2 ) ) 


Natsheh 02-09-2017 12:10

Re: get_user_flags
 
Quote:

Originally Posted by Bugsy (Post 2494122)
That will return true if the player has FLAG1 and/or FLAG2, but doesn't guarantee they have both. I also do not think your ~ condition would work as you expect.

Try this:
PHP Code:

if ( ( get_user_flagsid ) & ( FLAG1 FLAG2 FLAG3 ) ) == ( FLAG1 FLAG2 ) ) 


👏👏👏👏 your dam right

edon1337 02-09-2017 12:39

Re: get_user_flags
 
Quote:

Originally Posted by Bugsy (Post 2494122)
That will return true if the player has FLAG1 and/or FLAG2, but doesn't guarantee they have both. I also do not think your ~ condition would work as you expect.

Try this:
PHP Code:

if ( ( get_user_flagsid ) & ( FLAG1 FLAG2 FLAG3 ) ) == ( FLAG1 FLAG2 ) ) 


are you sure that's the same as
PHP Code:

if ( ( get_user_flagsid ) & FLAG1 ) && ( get_user_flagsid ) & FLAG2 ) && !( get_user_flagsid ) & FLAG3 ) ) 

because I want this but in a more efficient way

Natsheh 02-09-2017 12:47

Re: get_user_flags
 
Hes damn right ....

Bugsy 02-09-2017 12:49

Re: get_user_flags
 
Why are you questioning this? My method is efficient.

edon1337 02-09-2017 13:04

Re: get_user_flags
 
No, I meant, is your method the same as
PHP Code:

if ( ( get_user_flagsid ) & FLAG1 ) && ( get_user_flagsid ) & FLAG2 ) && !( get_user_flagsid ) & FLAG3 ) ) 

btw how to check if player has FLAG1 , FLAG2 and FLAG3

Bugsy 02-09-2017 13:06

Re: get_user_flags
 
Yes, it does the same thing..exactly what you asked for in your first post.

To check if has all, just add FLAG3 to the == value.
PHP Code:

if ( ( get_user_flagsid ) & ( FLAG1 FLAG2 FLAG3 ) ) == ( FLAG1 FLAG2 FLAG3 ) ) 


edon1337 02-09-2017 16:31

Re: get_user_flags
 
Quote:

Originally Posted by Bugsy (Post 2494149)
Yes, it does the same thing..exactly what you asked for in your first post.

To check if has all, just add FLAG3 to the == value.
PHP Code:

if ( ( get_user_flagsid ) & ( FLAG1 FLAG2 FLAG3 ) ) == ( FLAG1 FLAG2 FLAG3 ) ) 


Thanks but, can you explain the logic behind this? I still don't get it (the == part)

EDIT : So you're checking for 3 flags if they're equal to 3 others. Ah I get it now. Thanks a lot.


All times are GMT -4. The time now is 20:52.

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