Raised This Month: $ Target: $400
 0% 

Solved get_user_flags


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 02-09-2017 , 11:15   get_user_flags
Reply With Quote #1

Hi.

How would I check :

User has FLAG_1 and FLAG_2 but not FLAG_3
__________________

Last edited by edon1337; 02-11-2017 at 11:27.
edon1337 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 02-09-2017 , 11:22   Re: get_user_flags
Reply With Quote #2

If(get_user_flag(id) & FLAG3) == FLAG3) return

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

FLAG123 MUST BE BITSUMS

Last edited by Natsheh; 02-09-2017 at 12:34.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-09-2017 , 11:32   Re: get_user_flags
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post
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 ) ) 
__________________

Last edited by Bugsy; 02-09-2017 at 11:37.
Bugsy is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 02-09-2017 , 12:10   Re: get_user_flags
Reply With Quote #4

Quote:
Originally Posted by Bugsy View Post
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
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 02-09-2017 , 12:39   Re: get_user_flags
Reply With Quote #5

Quote:
Originally Posted by Bugsy View Post
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
__________________

Last edited by edon1337; 02-09-2017 at 12:40.
edon1337 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 02-09-2017 , 12:47   Re: get_user_flags
Reply With Quote #6

Hes damn right ....
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-09-2017 , 12:49   Re: get_user_flags
Reply With Quote #7

Why are you questioning this? My method is efficient.
__________________
Bugsy is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 02-09-2017 , 13:04   Re: get_user_flags
Reply With Quote #8

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
__________________

Last edited by edon1337; 02-09-2017 at 13:04.
edon1337 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-09-2017 , 13:06   Re: get_user_flags
Reply With Quote #9

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 ) ) 
__________________
Bugsy is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 02-09-2017 , 16:31   Re: get_user_flags
Reply With Quote #10

Quote:
Originally Posted by Bugsy View Post
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.
__________________

Last edited by edon1337; 02-09-2017 at 16:33.
edon1337 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 20:52.


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