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

Check if user has a flag


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
G[o]Q
Member
Join Date: Jan 2010
Location: Poland (Malopolska)
Old 10-26-2015 , 07:00   Check if user has a flag
Reply With Quote #1

Hi

I want to check if user has a flag from conVar my code is like this:

Code:
public has_user_flag(client){
	decl String:cvar_flags;
	GetConVarString(sm_pgr_bonus_flag, cvar_flags, sizeof(cvar_flags));
	
	new AdminFlag:flag;
	
	FindFlagByChar(cvar_flags,flag);
	
	new flags = GetUserFlagBits(client); 
	
	return flags & flag;
}
is it ok ? I want to set letter of flag in conVar and check if user has this flag
G[o]Q is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 10-26-2015 , 14:52   Re: Check if user has a flag
Reply With Quote #2

Please no flags... Use CheckCommandAccess and then set access via overrides in SM.
Check this here on SM forum...
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
G[o]Q
Member
Join Date: Jan 2010
Location: Poland (Malopolska)
Old 10-26-2015 , 20:27   Re: Check if user has a flag
Reply With Quote #3

so, ok but I don't use any command 4 example i want to check flag after spawn and if user has a flag from conVar then i give him +20 hp, so can i use checkCommandAccess and be working?
G[o]Q is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 10-26-2015 , 23:12   Re: Check if user has a flag
Reply With Quote #4

Yes, use CheckCommandAccess. The string that you use with CheckCommandAccess doesn't have to actually exist.

PHP Code:
if (CheckCommandAccess(client"Give20ExtraHpOrWhatever"ADMFLAG_CUSTOM1true) {
    
//give the 20 hp here

Then, you can customize what flag gets the 20hp by plugging "Give20ExtraHpOrWhatever" into your admin_overrides.cfg. If you don't do that, then the default flag it will use will be CUSTOM 1
__________________

Last edited by ddhoward; 10-26-2015 at 23:12.
ddhoward is offline
G[o]Q
Member
Join Date: Jan 2010
Location: Poland (Malopolska)
Old 10-27-2015 , 05:46   Re: Check if user has a flag
Reply With Quote #5

ok i understand but i want to get flag from conVar it's only for learning so what can i do this if i conVar sm_my_flag and i set it to "c" what can I convert it to ADMFLAG_KICK ? i don't want to add new command only get flag from conVar and check if user has it
G[o]Q is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 10-28-2015 , 04:03   Re: Check if user has a flag
Reply With Quote #6

Setting access requirements using convars is an anti-pattern and should not be done - use the overrides system.
__________________
asherkin is offline
G[o]Q
Member
Join Date: Jan 2010
Location: Poland (Malopolska)
Old 10-28-2015 , 04:56   Re: Check if user has a flag
Reply With Quote #7

i don't want to use it on server I only want to know how to do it only for fun
G[o]Q is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 10-28-2015 , 06:26   Re: Check if user has a flag
Reply With Quote #8

Yeah, I am already laughing :-D
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 10-28-2015 , 10:22   Re: Check if user has a flag
Reply With Quote #9

does that function not work or what is the issue?
Miu is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 10-28-2015 , 13:48   Re: Check if user has a flag
Reply With Quote #10

Since how to check admin flags is a pretty common question, I wrote up a quick thing about the most common ways to do it and tossed it on the wiki.

Granted, being a wiki, if people see something wrong on it, they can fix it.
__________________
Not currently working on SourceMod plugin development.
Powerlord 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 09:32.


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