Raised This Month: $ Target: $400
 0% 

cmdaccess.ini & get_user_flags()


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hypheni
Senior Member
Join Date: Jul 2011
Location: India
Old 01-14-2013 , 12:59   cmdaccess.ini & get_user_flags()
Reply With Quote #1

I have totally custom cmdaccess.ini.

PHP Code:
"amx_kick"                "a" admincmd.amxx
"amx_ban"                "a" admincmd.amxx
"amx_banip"                "a" admincmd.amxx
"amx_addban"            "a" admincmd.amxx
"amx_unban"            "a" admincmd.amxx

"amx_pausecfg"            "g" pausecfg.amxx
"amx_pausecfgmenu"        "g" pausecfg.amxx
"amx_off"                "g" pausecfg.amxx
"amx_on"                 "g" pausecfg.amxx 
Now depending on Admin category they gets these flags.

What should be the proper value of get_user_flags() to check admin type and also what to check for non-admin users

Last edited by hypheni; 01-14-2013 at 13:00.
hypheni is offline
Send a message via Skype™ to hypheni
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-14-2013 , 20:09   Re: cmdaccess.ini & get_user_flags()
Reply With Quote #2

Can't exactly understand you. You need to explain it better. As I see it, you just do what you would always do based on your example of cmdaccess.ini.

When you change cmdaccess.ini, you need not edit any plugins to make it work. If an admin has flag "a" then they can use amx_kick. If an admin has flag "g", they can use amx_off.
__________________
fysiks is offline
hypheni
Senior Member
Join Date: Jul 2011
Location: India
Old 01-15-2013 , 01:26   Re: cmdaccess.ini & get_user_flags()
Reply With Quote #3

^^Thanks mate for quick response.

What I wanted to know is that, how can I check from my Plugin which admin has which flag ?.

get_user_flag(id) == ??

And what it would return for normal non-admin players.

Last edited by hypheni; 01-15-2013 at 02:09.
hypheni is offline
Send a message via Skype™ to hypheni
hypheni
Senior Member
Join Date: Jul 2011
Location: India
Old 01-15-2013 , 02:15   Re: cmdaccess.ini & get_user_flags()
Reply With Quote #4

I have found these defines:

PHP Code:
Admin Level Constants
#define ADMIN_ALL        0    //Everyone
#define ADMIN_IMMUNITY        1    //Flag "a", immunity
#define ADMIN_RESERVATION    2    //Flag "b", reservation
#define ADMIN_KICK        4    //Flag "c", kick
#define ADMIN_BAN        8    //Flag "d", ban
#define ADMIN_SLAY        16    //Flag "e", slay
#define ADMIN_MAP        32    //Flag "f", map change
#define ADMIN_CVAR        64    //Flag "g", cvar change
#define ADMIN_CFG        128    //Flag "h", config execution
#define ADMIN_CHAT        256    //Flag "i", chat
#define ADMIN_VOTE        512    //Flag "j", vote
#define ADMIN_PASSWORD        1024    //Flag "k", sv_password
#define ADMIN_RCON        2048    //Flag "l", rcon access
#define ADMIN_LEVEL_A        4096    //Flag "m", custom
#define ADMIN_LEVEL_B        8192    //Flag "n", custom
#define ADMIN_LEVEL_C        16384    //Flag "o", custom
#define ADMIN_LEVEL_D        32768    //Flag "p", custom
#define ADMIN_LEVEL_E        65536    //Flag "q", custom
#define ADMIN_LEVEL_F        131072    //Flag "r", custom
#define ADMIN_LEVEL_G        262144    //Flag "s", custom
#define ADMIN_LEVEL_H        524288    //Flag "t", custom
#define ADMIN_MENU        1048576    //Flag "u", menus
#define ADMIN_ADMIN        16777216    //Flag "y", default admin
#define ADMIN_USER        33554432    //Flag "z", default user 
So normal non-admin users falls under ADMIN_ALL and according to my cmdaccess.ini I should check ADMIN_IMMUNITY (flag "a") or ADMIN_CVAR (flag "g").

Am I correct ?
hypheni is offline
Send a message via Skype™ to hypheni
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 01-15-2013 , 02:17   Re: cmdaccess.ini & get_user_flags()
Reply With Quote #5

No, users that you do not define as admins will have whatever flags you list in the cvar amx_default_access. Any flag other than Z means, to AMXX, that the user is an admin.
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
hypheni
Senior Member
Join Date: Jul 2011
Location: India
Old 01-15-2013 , 03:50   Re: cmdaccess.ini & get_user_flags()
Reply With Quote #6

So my simple query is with my above cmdaccess.ini how to check Admin and Non-Admin user from amx code.

PHP Code:
if(get_user_flag(id) == ADMIN_IMMUNITY)
  
server_cmd("echo client is Admin")
else if(
get_user_flag(id) == ADMIN_USER)
  
server_cmd("echo client is Non-Admin"

Last edited by hypheni; 01-15-2013 at 03:52.
hypheni is offline
Send a message via Skype™ to hypheni
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 01-15-2013 , 04:20   Re: cmdaccess.ini & get_user_flags()
Reply With Quote #7

Ex :
PHP Code:
if(get_user_flags(id) & ADMIN_IMMUNITY

Last edited by EpicMonkey; 01-15-2013 at 04:20.
EpicMonkey is offline
hypheni
Senior Member
Join Date: Jul 2011
Location: India
Old 01-15-2013 , 04:29   Re: cmdaccess.ini & get_user_flags()
Reply With Quote #8

One thing about get_user_flags()

As per documentation it says get_user_flags ( index, id = 0 )

and to read from sever we need to set index = 0 but we always use get_user_flags (id) ie: using 1 argument that is user's id. Is that correct ?
hypheni is offline
Send a message via Skype™ to hypheni
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-15-2013 , 19:59   Re: cmdaccess.ini & get_user_flags()
Reply With Quote #9

What are you actually trying to do?????? You are making no sense by referring to the commands listed in cmdaccess.ini. Again, if you change a flag in cmdaccess.ini you do not need to do anything to the plugins unless there is some specific functionality required (I can only think of two situation right now, that is if you want to require that a person have ONLY that single flag or require that they have multiple flags).

If you want to know if a player has a specific flag then you do it like EpicMonkey has showed. Ignore the second argument completely. Just because the second argument is named as "id" it doesn't mean it has anything to do with the "id" that you use as the first argument in a plugin.
__________________

Last edited by fysiks; 01-15-2013 at 20:01.
fysiks is offline
hypheni
Senior Member
Join Date: Jul 2011
Location: India
Old 01-17-2013 , 02:20   Re: cmdaccess.ini & get_user_flags()
Reply With Quote #10

My doubt was if I change Admin access in users.ini I also have to change get_users_flags() with that check.

Now its clear. Admin should have that access which is required for particular plugin cmd to execute and get_users_flags() always checks for fixed access ie: ADMIN_IMMUNITY(a) or ADMIN_CVAR(g).

And all these macros are #define in amx inc ie: #define ADMIN_IMMUNITY "a" and so on.
hypheni is offline
Send a message via Skype™ to hypheni
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 13:41.


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