Raised This Month: $51 Target: $400
 12% 

Checking if client has a flag


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
condolent
AlliedModders Donor
Join Date: Jan 2016
Location: gc_sLocation;
Old 07-27-2017 , 07:32   Checking if client has a flag
Reply With Quote #1

How can I check if a client has the ADMFLAG_RESERVATION flag? The plugin has no commands so CheckCommandAccess won't really work
__________________
condolent is offline
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 07-27-2017 , 07:39   Re: Checking if client has a flag
Reply With Quote #2

Pretty certain it'll work without an actual command being there, look at last 2 parameters: https://sm.alliedmods.net/new-api/co...kCommandAccess

Can also use GetUserAdmin and GetAdminFlags
hmmmmm is offline
condolent
AlliedModders Donor
Join Date: Jan 2016
Location: gc_sLocation;
Old 07-27-2017 , 07:40   Re: Checking if client has a flag
Reply With Quote #3

Quote:
Originally Posted by hmmmmm View Post
Pretty certain it'll work without an actual command being there, look at last 2 parameters: https://sm.alliedmods.net/new-api/co...kCommandAccess

Can also use GetUserAdmin and GetAdminFlags
Did not see that last parameter, lol! Thanks
__________________
condolent is offline
inklesspen
Member
Join Date: Nov 2015
Location: Russia, Moscow
Old 07-27-2017 , 08:09   Re: Checking if client has a flag
Reply With Quote #4

if(GetUserFlagBits(client) & ADMFLAG_...)
// do something
__________________
Mai inglish is veri gud!
inklesspen is offline
Send a message via Skype™ to inklesspen
plx211
AlliedModders Donor
Join Date: Mar 2016
Location: Poland
Old 07-27-2017 , 08:35   Re: Checking if client has a flag
Reply With Quote #5

Code:
stock bool CheckClientFlag(int client, AdminFlag flag) {
  AdminId adminID = GetUserAdmin(client);
  return adminID == INVALID_ADMIN_ID ? false : adminID.HasFlag(flag);
}


if (CheckClientFlag(client, Admin_Reservation)) {
  //...
}
__________________

Last edited by plx211; 07-27-2017 at 08:37.
plx211 is offline
ambn
Veteran Member
Join Date: Feb 2015
Location: Fun servers
Old 07-28-2017 , 00:25   Re: Checking if client has a flag
Reply With Quote #6

Quote:
Originally Posted by hmmmmm View Post
Pretty certain it'll work without an actual command being there, look at last 2 parameters: https://sm.alliedmods.net/new-api/co...kCommandAccess

Can also use GetUserAdmin and GetAdminFlags
This will not always work, because a client with flag Root will always mark this boolean as true, i suggest using FlagBits for Checking a single flag is better.
__________________
ambn is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 07-28-2017 , 01:11   Re: Checking if client has a flag
Reply With Quote #7

Quote:
Originally Posted by ambn View Post
This will not always work, because a client with flag Root will always mark this boolean as true, i suggest using FlagBits for Checking a single flag is better.
Well, that's the purpose of having root flag, to have access to all flags.
__________________
Chaosxk is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 07-28-2017 , 05:28   Re: Checking if client has a flag
Reply With Quote #8

...don't use or give root flag z to anyone, then this admin system will work better. Seems most don't want to believe this.
__________________
Do not Private Message @me
Bacardi is offline
ambn
Veteran Member
Join Date: Feb 2015
Location: Fun servers
Old 07-28-2017 , 06:26   Re: Checking if client has a flag
Reply With Quote #9

Quote:
Originally Posted by Bacardi View Post
...don't use or give root flag z to anyone, then this admin system will work better. Seems most don't want to believe this.

I strongly accept your idea, i my self have many servers but no one but me has flag z , what i meant above is if he is going to check flags of all users in a loop to apply some stuff, CheckCommandAcceas is not a good choice..
__________________
ambn 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 10:43.


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