@ for the admin-only channel, @@ for a coloured server announcement, @@@ for a HUD message.
csb_admin_chat.sma v1.0.0
1
/*
2
* CSB Admin Chat
3
* Copyright (C) 2026 counter-strike-boost.com
4
*
5
* Prefixed admin chat channels:
6
* @text -> private channel, only admins see it
7
* @@text -> coloured server announcement to everyone
8
* @@@text -> centred HUD message to everyone
9
*
10
* Inspired by "Admin Chat Colored" by AlexALX. This is an independent GPL
11
* re-implementation written from scratch.
12
*
13
* This program is free software: you can redistribute it and/or modify it under
14
* the terms of the GNU General Public License as published by the Free Software
15
* Foundation, either version 3 of the License, or (at your option) any later
16
* version. It is distributed in the hope that it will be useful, but WITHOUT ANY
17
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18
* A PARTICULAR PURPOSE. See <https://www.gnu.org/licenses/> for details.
19
*/
20
21
#include <amxmodx>
22
#include <amxmisc>
23
24
new const PLUGIN[] = "CSB Admin Chat"
25
new const VERSION[] = "1.0.0"
26
new const AUTHOR[] = "counter-strike-boost.com"
27
28
new g_pEnabled, g_pFlag, g_pPrefix, g_pHudRed, g_pHudGreen, g_pHudBlue, g_pHudHold
29
new g_msgSayText
30
31
public plugin_init()
32
{
33
register_plugin(PLUGIN, VERSION, AUTHOR)
34
35
g_pEnabled = register_cvar("csb_achat_enabled", "1")
36
g_pFlag = register_cvar("csb_achat_flag", "d") /* ADMIN_BAN by default */
37
g_pPrefix = register_cvar("csb_achat_prefix", "ADMIN")
38
g_pHudRed = register_cvar("csb_achat_hud_r", "255")
39
g_pHudGreen = register_cvar("csb_achat_hud_g", "160")
40
g_pHudBlue = register_cvar("csb_achat_hud_b", "0")
41
g_pHudHold = register_cvar("csb_achat_hud_hold", "6.0")
42
43
register_clcmd("say", "cmdSay")
44
register_clcmd("say_team", "cmdSay")
45
46
g_msgSayText = get_user_msgid("SayText")
47
}
48
49
public cmdSay(id)
50
{
51
if (!get_pcvar_num(g_pEnabled))
52
return PLUGIN_CONTINUE
53
54
new said[192]
55
read_args(said, charsmax(said))
56
remove_quotes(said)
57
trim(said)
58
59
if (said[0] != '@')
60
return PLUGIN_CONTINUE
61
62
new flagStr[8]
63
get_pcvar_string(g_pFlag, flagStr, charsmax(flagStr))
64
65
if (!(get_user_flags(id) & read_flags(flagStr)))
66
return PLUGIN_CONTINUE
67
68
new level = 0
69
70
while (level < 3 && said[level] == '@')
71
level++
72
73
new text[192]
74
copy(text, charsmax(text), said[level])
75
trim(text)
76
77
if (!text[0])
78
{
79
client_print(id, print_chat, "[CSB] Usage: @message (admins) / @@message (all) / @@@message (HUD)")
80
return PLUGIN_HANDLED
81
}
82
83
new name[32], prefix[24]
84
get_user_name(id, name, charsmax(name))
85
get_pcvar_string(g_pPrefix, prefix, charsmax(prefix))
86
87
switch (level)
88
{
89
case 1: sendAdminChat(id, name, prefix, text)
90
case 2: sendPublicChat(id, name, prefix, text)
91
case 3: sendHudMessage(id, name, prefix, text)
92
}
93
94
logIt(id, level, text)
95
return PLUGIN_HANDLED
96
}
97
98
sendAdminChat(id, const name[], const prefix[], const text[])
99
{
100
new buf[192], flagStr[8]
101
get_pcvar_string(g_pFlag, flagStr, charsmax(flagStr))
102
103
new flags = read_flags(flagStr)
104
new alive = is_user_alive(id) ? 0 : 1
105
106
formatex(buf, charsmax(buf), "^x04(%s)%s^x03 %s^x01 : %s", prefix, alive ? "(DEAD)" : "", name, text)
107
108
new players[32], num, pid
109
get_players(players, num, "ch")
110
111
for (new i = 0; i < num; i++)
112
{
113
pid = players[i]
114
115
if (!(get_user_flags(pid) & flags))
116
continue
117
118
message_begin(MSG_ONE, g_msgSayText, _, pid)
119
write_byte(id)
120
write_string(buf)
121
message_end()
122
}
123
}
124
125
sendPublicChat(id, const name[], const prefix[], const text[])
126
{
127
new buf[192]
128
formatex(buf, charsmax(buf), "^x04[%s]^x03 %s^x01 : ^x04%s", prefix, name, text)
129
130
new players[32], num
131
get_players(players, num, "ch")
132
133
for (new i = 0; i < num; i++)
134
{
135
message_begin(MSG_ONE, g_msgSayText, _, players[i])
136
write_byte(id)
137
write_string(buf)
138
message_end()
139
}
140
}
141
142
sendHudMessage(id, const name[], const prefix[], const text[])
143
{
144
new Float:hold = get_pcvar_float(g_pHudHold)
145
146
if (hold < 1.0)
147
hold = 1.0
148
149
set_hudmessage(get_pcvar_num(g_pHudRed), get_pcvar_num(g_pHudGreen), get_pcvar_num(g_pHudBlue),
150
-1.0, 0.25, 0, 0.5, hold, 0.1, 0.2, 4)
151
152
show_hudmessage(0, "[%s] %s:^n%s", prefix, name, text)
153
154
/* a HUD message is easy to miss, so mirror it in chat as well */
155
new buf[192]
156
formatex(buf, charsmax(buf), "^x04[%s]^x03 %s^x01 : ^x04%s", prefix, name, text)
157
158
new players[32], num
159
get_players(players, num, "ch")
160
161
for (new i = 0; i < num; i++)
162
{
163
message_begin(MSG_ONE, g_msgSayText, _, players[i])
164
write_byte(id)
165
write_string(buf)
166
message_end()
167
}
168
}
169
170
logIt(id, level, const text[])
171
{
172
new name[32], authid[35]
173
get_user_name(id, name, charsmax(name))
174
get_user_authid(id, authid, charsmax(authid))
175
176
new channel[16]
177
178
switch (level)
179
{
180
case 1: copy(channel, charsmax(channel), "admins")
181
case 2: copy(channel, charsmax(channel), "all")
182
case 3: copy(channel, charsmax(channel), "hud")
183
}
184
185
log_amx("[CSB Admin Chat] %s <%s> (%s): %s", name, authid, channel, text)
186
}
187









