AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   cmdaccess.ini & get_user_flags() (https://forums.alliedmods.net/showthread.php?t=205778)

hypheni 01-14-2013 12:59

cmdaccess.ini & get_user_flags()
 
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

fysiks 01-14-2013 20:09

Re: cmdaccess.ini & get_user_flags()
 
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.

hypheni 01-15-2013 01:26

Re: cmdaccess.ini & get_user_flags()
 
^^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.

hypheni 01-15-2013 02:15

Re: cmdaccess.ini & get_user_flags()
 
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 ?

YamiKaitou 01-15-2013 02:17

Re: cmdaccess.ini & get_user_flags()
 
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.

hypheni 01-15-2013 03:50

Re: cmdaccess.ini & get_user_flags()
 
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"


EpicMonkey 01-15-2013 04:20

Re: cmdaccess.ini & get_user_flags()
 
Ex :
PHP Code:

if(get_user_flags(id) & ADMIN_IMMUNITY


hypheni 01-15-2013 04:29

Re: cmdaccess.ini & get_user_flags()
 
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 ?

fysiks 01-15-2013 19:59

Re: cmdaccess.ini & get_user_flags()
 
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.

hypheni 01-17-2013 02:20

Re: cmdaccess.ini & get_user_flags()
 
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.


All times are GMT -4. The time now is 13:41.

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