Raised This Month: $ Target: $400
 0% 

Flags related


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EDUTz
Senior Member
Join Date: Jun 2010
Location: Dracula's Homeland
Old 09-17-2012 , 06:22   Flags related
Reply With Quote #1

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.

Last edited by EDUTz; 09-17-2012 at 06:23.
EDUTz is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 09-17-2012 , 07:29   Re: Flags related
Reply With Quote #2

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

Last edited by jimaway; 09-17-2012 at 07:30.
jimaway is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 09-17-2012 , 09:53   Re: Flags related
Reply With Quote #3

NOT logical isn't ~ ?
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 09-17-2012 , 10:57   Re: Flags related
Reply With Quote #4

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

Last edited by jimaway; 09-17-2012 at 10:59.
jimaway is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 09-17-2012 , 12:49   Re: Flags related
Reply With Quote #5

Oh , now understand , thanks you jima.
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 09-17-2012 , 16:03   Re: Flags related
Reply With Quote #6

So, more exactly:

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

Last edited by claudiuhks; 09-17-2012 at 16:04.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
EDUTz
Senior Member
Join Date: Jun 2010
Location: Dracula's Homeland
Old 09-17-2012 , 23:15   Re: Flags related
Reply With Quote #7

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 ...
EDUTz is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-17-2012 , 23:32   Re: Flags related
Reply With Quote #8

Code:
if( get_user_flags(id) & (ADMIN_MAP | ADMIN_SLAY) == (ADMIN_MAP | ADMIN_SLAY) )
{
	// Has only flags "e" and "f".
}
__________________
fysiks is offline
Old 09-17-2012, 23:36
Bos93
This message has been deleted by Bos93.
EDUTz
Senior Member
Join Date: Jun 2010
Location: Dracula's Homeland
Old 09-17-2012 , 23:56   Re: Flags related
Reply With Quote #9

that makes more sense.
Anyway, it doesn't work either.

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

Last edited by EDUTz; 09-18-2012 at 00:18.
EDUTz is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-18-2012 , 19:01   Re: Flags related
Reply With Quote #10

Quote:
Originally Posted by EDUTz View Post
that makes more sense.
Anyway, it doesn't work either.

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)
__________________
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 08:15.


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