Raised This Month: $ Target: $400
 0% 

How to get user Flags


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 05-13-2013 , 14:33   Re: How to get user Flags
Reply With Quote #1

Thats the problem... I use flags as "t" etc not ADMIN_LEVEL_H etc
__________________
Jhob94 is offline
dFF
sıɹɹoɥɔ ʞɔnu
Join Date: Oct 2009
Old 05-13-2013 , 14:38   Re: How to get user Flags
Reply With Quote #2

PHP Code:
if( has_flagid"t" ) )
{
    
// code
}

if( 
has_all_flagsid"bt" ) )
{
    
// code

dFF is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-13-2013 , 14:49   Re: How to get user Flags
Reply With Quote #3

Quote:
Originally Posted by Jhob94 View Post
Thats the problem... I use flags as "t" etc not ADMIN_LEVEL_H etc
If you prefer using the letter, for whatever reason, you can use this macro.

PHP Code:
#define FlagByLetter(%1) (1<<((%1-'a')))

if ( get_user_flagsid ) & FlagByLetter't' ) )
{


__________________

Last edited by Bugsy; 05-13-2013 at 14:51.
Bugsy is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 05-13-2013 , 14:56   Re: How to get user Flags
Reply With Quote #4

Quote:
Originally Posted by Bugsy View Post
If you prefer using the letter, for whatever reason, you can use this macro.

PHP Code:
#define FlagByLetter(%1) (1<<((%1-'a')))

if ( get_user_flagsid ) & FlagByLetter't' ) )
{


How to make "t" instead of 't'?
__________________
Jhob94 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-13-2013 , 15:00   Re: How to get user Flags
Reply With Quote #5

has_flag(id, "t")

One of flags "pqr" : has_flag(id, "pqr")

All "pqr" flags : has_all_flags(id, "pqr");


If you want to directly use , t), you would have to define all letters, but then you wouldn't be able to use anymore a sibgle letter as variable name such as for(new i; i<num; i++) because i would already be equal to ADMIN_LEVEL_*
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 05-13-2013 , 15:09   Re: How to get user Flags
Reply With Quote #6

Quote:
Originally Posted by ConnorMcLeod View Post
has_flag(id, "t")

One of flags "pqr" : has_flag(id, "pqr")

All "pqr" flags : has_all_flags(id, "pqr");


If you want to directly use , t), you would have to define all letters, but then you wouldn't be able to use anymore a sibgle letter as variable name such as for(new i; i<num; i++) because i would already be equal to ADMIN_LEVEL_*
Thanks
But if i have "apqr" and i use has_all_flags(id, "pqr") i still valid even have more flags right?
__________________
Jhob94 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-13-2013 , 15:26   Re: How to get user Flags
Reply With Quote #7

Quote:
Originally Posted by Jhob94 View Post
Thanks
But if i have "apqr" and i use has_all_flags(id, "pqr") i still valid even have more flags right?
Yes

If you want to check if a user has only what you specify, you could do:
PHP Code:
const FLAGS_TO_CHECK ADMIN_FLAG_E ADMIN_FLAG_H ADMIN_FLAG_J;

if ( 
get_user_flagsid ) == FLAGS_TO_CHECK )
{

}

//or this (includes 'standard' flags that every admin will have on your server)
const BASE_FLAGS ADMIN_KICK ADMIN_BAN ADMIN_SLAY;
const 
FLAGS_TO_CHECK ADMIN_FLAG_E ADMIN_FLAG_H ADMIN_FLAG_J;

if ( 
get_user_flagsid ) == ( BASE_FLAGS FLAGS_TO_CHECK ) )
{


__________________

Last edited by Bugsy; 05-13-2013 at 15:29.
Bugsy 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 16:23.


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