Type /admins to see every online admin, their access flags and whether they are AFK.
csb_admin_list.sma v1.0.0
1
/*
2
* CSB Admin List
3
* Copyright (C) 2026 counter-strike-boost.com
4
*
5
* Shows every connected admin with their access level and AFK state.
6
* Inspired by the classic "Admins List" plugin by Alka. This is an
7
* independent GPL re-implementation; no original code is reused.
8
*
9
* This program is free software: you can redistribute it and/or modify it
10
* under the terms of the GNU General Public License as published by the Free
11
* Software Foundation, either version 3 of the License, or (at your option)
12
* any later version. It is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
* Public License for more details: <https://www.gnu.org/licenses/>.
16
*/
17
18
#include <amxmodx>
19
#include <amxmisc>
20
21
new const PLUGIN[] = "CSB Admin List"
22
new const VERSION[] = "1.0.0"
23
new const AUTHOR[] = "counter-strike-boost.com"
24
25
#define AFK_LIMIT 20 /* seconds without moving before we call it AFK */
26
27
new g_pEnabled, g_pHideFlag, g_pShowHidden
28
29
new g_iAdminFlags /* flags that make a player "an admin" */
30
new g_iAfkSeconds[33]
31
new Float:g_fLastOrigin[33][3]
32
33
public plugin_init()
34
{
35
register_plugin(PLUGIN, VERSION, AUTHOR)
36
37
g_pEnabled = register_cvar("csb_adminlist_enabled", "1")
38
g_pHideFlag = register_cvar("csb_adminlist_hideflag", "a")
39
g_pShowHidden = register_cvar("csb_adminlist_showhidden", "0")
40
41
register_clcmd("say /admins", "cmdAdmins")
42
register_clcmd("say_team /admins", "cmdAdmins")
43
register_clcmd("say /admin", "cmdAdmins")
44
45
/* any flag from a..t marks a real admin; z (ADMIN_USER) does not */
46
g_iAdminFlags = read_flags("abcdefghijklmnopqrst")
47
48
set_task(1.0, "taskAfkScan", 0, _, _, "b")
49
}
50
51
public client_connect(id)
52
{
53
g_iAfkSeconds[id] = 0
54
g_fLastOrigin[id][0] = 0.0
55
g_fLastOrigin[id][1] = 0.0
56
g_fLastOrigin[id][2] = 0.0
57
}
58
59
/* Track movement so we can flag AFK admins in the list. */
60
public taskAfkScan()
61
{
62
new players[32], num, id
63
get_players(players, num, "ch")
64
65
for (new i = 0; i < num; i++)
66
{
67
id = players[i]
68
69
if (!is_user_alive(id))
70
{
71
g_iAfkSeconds[id] = 0
72
continue
73
}
74
75
new Float:origin[3]
76
get_user_origin_f(id, origin)
77
78
if (floatabs(origin[0] - g_fLastOrigin[id][0]) < 2.0
79
&& floatabs(origin[1] - g_fLastOrigin[id][1]) < 2.0
80
&& floatabs(origin[2] - g_fLastOrigin[id][2]) < 2.0)
81
g_iAfkSeconds[id]++
82
else
83
g_iAfkSeconds[id] = 0
84
85
g_fLastOrigin[id][0] = origin[0]
86
g_fLastOrigin[id][1] = origin[1]
87
g_fLastOrigin[id][2] = origin[2]
88
}
89
}
90
91
/* get_user_origin returns integer cells; wrap it into floats for comparison */
92
get_user_origin_f(id, Float:out[3])
93
{
94
new iOrigin[3]
95
get_user_origin(id, iOrigin)
96
out[0] = float(iOrigin[0])
97
out[1] = float(iOrigin[1])
98
out[2] = float(iOrigin[2])
99
}
100
101
public cmdAdmins(id)
102
{
103
if (!get_pcvar_num(g_pEnabled))
104
{
105
client_print(id, print_chat, "[CSB] The admin list is disabled.")
106
return PLUGIN_HANDLED
107
}
108
109
new hideFlagStr[8], hideFlags, showHidden
110
get_pcvar_string(g_pHideFlag, hideFlagStr, charsmax(hideFlagStr))
111
hideFlags = read_flags(hideFlagStr)
112
showHidden = get_pcvar_num(g_pShowHidden)
113
114
/* a viewer who is an admin himself always sees hidden admins */
115
if (get_user_flags(id) & g_iAdminFlags)
116
showHidden = 1
117
118
new players[32], num, pid, listed = 0
119
get_players(players, num, "ch")
120
121
client_print_color(id, print_team_default, "^x04[CSB]^x01 Online admins:")
122
123
for (new i = 0; i < num; i++)
124
{
125
pid = players[i]
126
127
new flags = get_user_flags(pid)
128
129
if (!(flags & g_iAdminFlags))
130
continue
131
132
if ((flags & hideFlags) && hideFlags != 0 && !showHidden)
133
continue
134
135
new name[32], flagStr[27]
136
get_user_name(pid, name, charsmax(name))
137
get_flags(flags, flagStr, charsmax(flagStr))
138
139
new status[16]
140
if (!is_user_alive(pid))
141
copy(status, charsmax(status), "dead")
142
else if (g_iAfkSeconds[pid] >= AFK_LIMIT)
143
copy(status, charsmax(status), "AFK")
144
else
145
copy(status, charsmax(status), "active")
146
147
client_print_color(id, print_team_default,
148
"^x04*^x03 %s ^x01[flags: ^x04%s^x01] ^x01(%s)",
149
name, flagStr, status)
150
151
listed++
152
}
153
154
if (!listed)
155
client_print_color(id, print_team_default, "^x01 No admins are online right now.")
156
157
return PLUGIN_HANDLED
158
}
159









