Parent Directory | Revision Log
Revision 44 - (view) (download)
1 : | ian | 1 | /* AMX Mod X |
2 : | * Admin Chat Plugin | ||
3 : | * | ||
4 : | * by the AMX Mod X Development Team | ||
5 : | * originally developed by OLO | ||
6 : | * | ||
7 : | * This file is part of AMX Mod X. | ||
8 : | * | ||
9 : | * | ||
10 : | * This program is free software; you can redistribute it and/or modify it | ||
11 : | * under the terms of the GNU General Public License as published by the | ||
12 : | * Free Software Foundation; either version 2 of the License, or (at | ||
13 : | * your option) any later version. | ||
14 : | * | ||
15 : | * This program is distributed in the hope that it will be useful, but | ||
16 : | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 : | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
18 : | * General Public License for more details. | ||
19 : | * | ||
20 : | * You should have received a copy of the GNU General Public License | ||
21 : | * along with this program; if not, write to the Free Software Foundation, | ||
22 : | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
23 : | * | ||
24 : | * In addition, as a special exception, the author gives permission to | ||
25 : | * link the code of this program with the Half-Life Game Engine ("HL | ||
26 : | * Engine") and Modified Game Libraries ("MODs") developed by Valve, | ||
27 : | * L.L.C ("Valve"). You must obey the GNU General Public License in all | ||
28 : | * respects for all of the code used other than the HL Engine and MODs | ||
29 : | * from Valve. If you modify this file, you may extend this exception | ||
30 : | * to your version of the file, but you are not obligated to do so. If | ||
31 : | * you do not wish to do so, delete this exception statement from your | ||
32 : | * version. | ||
33 : | */ | ||
34 : | |||
35 : | #include <amxmodx> | ||
36 : | #include <amxmisc> | ||
37 : | |||
38 : | new g_msgChannel | ||
39 : | |||
40 : | #define MAX_CLR 10 | ||
41 : | |||
42 : | new g_Colors[MAX_CLR][] = {"COL_WHITE", "COL_RED", "COL_GREEN", "COL_BLUE", "COL_YELLOW", "COL_MAGENTA", "COL_CYAN", "COL_ORANGE", "COL_OCEAN", "COL_MAROON"} | ||
43 : | new g_Values[MAX_CLR][] = {{255, 255, 255}, {255, 0, 0}, {0, 255, 0}, {0, 0, 255}, {255, 255, 0}, {255, 0, 255}, {0, 255, 255}, {227, 96, 8}, {45, 89, 116}, {103, 44, 38}} | ||
44 : | new Float:g_Pos[4][] = {{0.0, 0.0}, {0.05, 0.55}, {-1.0, 0.2}, {-1.0, 0.7}} | ||
45 : | |||
46 : | ian | 17 | new amx_show_activity; |
47 : | ian | 44 | new g_AdminChatFlag = ADMIN_CHAT; |
48 : | |||
49 : | ian | 1 | public plugin_init() |
50 : | { | ||
51 : | ian | 44 | new admin_chat_id |
52 : | |||
53 : | ian | 1 | register_plugin("Admin Chat", AMXX_VERSION_STR, "AMXX Dev Team") |
54 : | register_dictionary("adminchat.txt") | ||
55 : | register_dictionary("common.txt") | ||
56 : | register_clcmd("say", "cmdSayChat", ADMIN_CHAT, "@[@|@|@][w|r|g|b|y|m|c]<text> - displays hud message") | ||
57 : | register_clcmd("say_team", "cmdSayAdmin", 0, "@<text> - displays message to admins") | ||
58 : | register_concmd("amx_say", "cmdSay", ADMIN_CHAT, "<message> - sends message to all players") | ||
59 : | ian | 44 | admin_chat_id = register_concmd("amx_chat", "cmdChat", ADMIN_CHAT, "<message> - sends message to admins") |
60 : | ian | 1 | register_concmd("amx_psay", "cmdPsay", ADMIN_CHAT, "<name or #userid> <message> - sends private message") |
61 : | register_concmd("amx_tsay", "cmdTsay", ADMIN_CHAT, "<color> <message> - sends left side hud message to all players") | ||
62 : | register_concmd("amx_csay", "cmdTsay", ADMIN_CHAT, "<color> <message> - sends center hud message to all players") | ||
63 : | ian | 17 | |
64 : | amx_show_activity = get_cvar_pointer("amx_show_activity"); | ||
65 : | |||
66 : | if (amx_show_activity == 0) | ||
67 : | { | ||
68 : | amx_show_activity = register_cvar("amx_show_activity", "2"); | ||
69 : | } | ||
70 : | ian | 44 | |
71 : | new str[1] | ||
72 : | get_concmd(admin_chat_id, str, 0, g_AdminChatFlag, str, 0, -1) | ||
73 : | ian | 1 | } |
74 : | |||
75 : | public cmdSayChat(id) | ||
76 : | { | ||
77 : | ian | 44 | if (!access(id, g_AdminChatFlag)) |
78 : | ian | 1 | { |
79 : | return PLUGIN_CONTINUE | ||
80 : | } | ||
81 : | |||
82 : | new said[6], i = 0 | ||
83 : | read_argv(1, said, 5) | ||
84 : | |||
85 : | while (said[i] == '@') | ||
86 : | { | ||
87 : | i++ | ||
88 : | } | ||
89 : | |||
90 : | if (!i || i > 3) | ||
91 : | { | ||
92 : | return PLUGIN_CONTINUE | ||
93 : | } | ||
94 : | |||
95 : | new message[192], a = 0 | ||
96 : | read_args(message, 191) | ||
97 : | remove_quotes(message) | ||
98 : | |||
99 : | switch (said[i]) | ||
100 : | { | ||
101 : | case 'r': a = 1 | ||
102 : | case 'g': a = 2 | ||
103 : | case 'b': a = 3 | ||
104 : | case 'y': a = 4 | ||
105 : | case 'm': a = 5 | ||
106 : | case 'c': a = 6 | ||
107 : | case 'o': a = 7 | ||
108 : | } | ||
109 : | |||
110 : | new n, s = i | ||
111 : | if (a) | ||
112 : | { | ||
113 : | n++ | ||
114 : | s++ | ||
115 : | } | ||
116 : | while (said[s] && isspace(said[s])) | ||
117 : | { | ||
118 : | n++ | ||
119 : | s++ | ||
120 : | } | ||
121 : | |||
122 : | |||
123 : | new name[32], authid[32], userid | ||
124 : | |||
125 : | get_user_authid(id, authid, 31) | ||
126 : | get_user_name(id, name, 31) | ||
127 : | userid = get_user_userid(id) | ||
128 : | |||
129 : | log_amx("Chat: ^"%s<%d><%s><>^" tsay ^"%s^"", name, userid, authid, message[i + n]) | ||
130 : | log_message("^"%s<%d><%s><>^" triggered ^"amx_tsay^" (text ^"%s^") (color ^"%L^")", name, userid, authid, message[i + n], "en", g_Colors[a]) | ||
131 : | |||
132 : | if (++g_msgChannel > 6 || g_msgChannel < 3) | ||
133 : | { | ||
134 : | g_msgChannel = 3 | ||
135 : | } | ||
136 : | |||
137 : | new Float:verpos = g_Pos[i][1] + float(g_msgChannel) / 35.0 | ||
138 : | |||
139 : | set_hudmessage(g_Values[a][0], g_Values[a][1], g_Values[a][2], g_Pos[i][0], verpos, 0, 6.0, 6.0, 0.5, 0.15, -1) | ||
140 : | |||
141 : | ian | 17 | switch ( get_pcvar_num(amx_show_activity) ) |
142 : | ian | 1 | { |
143 : | ian | 17 | case 3, 4: |
144 : | { | ||
145 : | new maxpl = get_maxplayers(); | ||
146 : | for (new pl = 1; pl <= maxpl; pl++) | ||
147 : | { | ||
148 : | if (is_user_connected(pl) && !is_user_bot(pl)) | ||
149 : | { | ||
150 : | if (is_user_admin(pl)) | ||
151 : | { | ||
152 : | show_hudmessage(pl, "%s : %s", name, message[i + n]) | ||
153 : | client_print(pl, print_notify, "%s : %s", name, message[i + n]) | ||
154 : | } | ||
155 : | else | ||
156 : | { | ||
157 : | show_hudmessage(pl, "%s", message[i + n]) | ||
158 : | client_print(pl, print_notify, "%s", message[i + n]) | ||
159 : | } | ||
160 : | } | ||
161 : | } | ||
162 : | } | ||
163 : | case 2: | ||
164 : | { | ||
165 : | show_hudmessage(0, "%s : %s", name, message[i + n]) | ||
166 : | client_print(0, print_notify, "%s : %s", name, message[i + n]) | ||
167 : | } | ||
168 : | default: | ||
169 : | { | ||
170 : | show_hudmessage(0, "%s", message[i + n]) | ||
171 : | client_print(0, print_notify, "%s", message[i + n]) | ||
172 : | } | ||
173 : | ian | 1 | } |
174 : | |||
175 : | return PLUGIN_HANDLED | ||
176 : | } | ||
177 : | |||
178 : | public cmdSayAdmin(id) | ||
179 : | { | ||
180 : | new said[2] | ||
181 : | read_argv(1, said, 1) | ||
182 : | |||
183 : | if (said[0] != '@') | ||
184 : | return PLUGIN_CONTINUE | ||
185 : | |||
186 : | new message[192], name[32], authid[32], userid | ||
187 : | new players[32], inum | ||
188 : | |||
189 : | read_args(message, 191) | ||
190 : | remove_quotes(message) | ||
191 : | get_user_authid(id, authid, 31) | ||
192 : | get_user_name(id, name, 31) | ||
193 : | userid = get_user_userid(id) | ||
194 : | |||
195 : | log_amx("Chat: ^"%s<%d><%s><>^" chat ^"%s^"", name, userid, authid, message[1]) | ||
196 : | log_message("^"%s<%d><%s><>^" triggered ^"amx_chat^" (text ^"%s^")", name, userid, authid, message[1]) | ||
197 : | |||
198 : | if (is_user_admin(id)) | ||
199 : | format(message, 191, "(%L) %s : %s", id, "ADMIN", name, message[1]) | ||
200 : | else | ||
201 : | format(message, 191, "(%L) %s : %s", id, "PLAYER", name, message[1]) | ||
202 : | |||
203 : | get_players(players, inum) | ||
204 : | |||
205 : | for (new i = 0; i < inum; ++i) | ||
206 : | { | ||
207 : | // dont print the message to the client that used the cmd if he has ADMIN_CHAT to avoid double printing | ||
208 : | ian | 44 | if (players[i] != id && get_user_flags(players[i]) & g_AdminChatFlag) |
209 : | ian | 1 | client_print(players[i], print_chat, "%s", message) |
210 : | } | ||
211 : | |||
212 : | client_print(id, print_chat, "%s", message) | ||
213 : | |||
214 : | return PLUGIN_HANDLED | ||
215 : | } | ||
216 : | |||
217 : | public cmdChat(id, level, cid) | ||
218 : | { | ||
219 : | if (!cmd_access(id, level, cid, 2)) | ||
220 : | return PLUGIN_HANDLED | ||
221 : | |||
222 : | new message[192], name[32], players[32], inum, authid[32], userid | ||
223 : | |||
224 : | read_args(message, 191) | ||
225 : | remove_quotes(message) | ||
226 : | get_user_authid(id, authid, 31) | ||
227 : | get_user_name(id, name, 31) | ||
228 : | userid = get_user_userid(id) | ||
229 : | get_players(players, inum) | ||
230 : | |||
231 : | log_amx("Chat: ^"%s<%d><%s><>^" chat ^"%s^"", name, userid, authid, message) | ||
232 : | log_message("^"%s<%d><%s><>^" triggered ^"amx_chat^" (text ^"%s^")", name, userid, authid, message) | ||
233 : | |||
234 : | format(message, 191, "(ADMINS) %s : %s", name, message) | ||
235 : | console_print(id, "%s", message) | ||
236 : | |||
237 : | for (new i = 0; i < inum; ++i) | ||
238 : | { | ||
239 : | ian | 44 | if (access(players[i], g_AdminChatFlag)) |
240 : | ian | 1 | client_print(players[i], print_chat, "%s", message) |
241 : | } | ||
242 : | |||
243 : | return PLUGIN_HANDLED | ||
244 : | } | ||
245 : | |||
246 : | public cmdSay(id, level, cid) | ||
247 : | { | ||
248 : | if (!cmd_access(id, level, cid, 2)) | ||
249 : | return PLUGIN_HANDLED | ||
250 : | |||
251 : | new message[192], name[32], authid[32], userid | ||
252 : | |||
253 : | read_args(message, 191) | ||
254 : | remove_quotes(message) | ||
255 : | get_user_authid(id, authid, 31) | ||
256 : | get_user_name(id, name, 31) | ||
257 : | userid = get_user_userid(id) | ||
258 : | client_print(0, print_chat, "%L", LANG_PLAYER, "PRINT_ALL", name, message) | ||
259 : | console_print(id, "%L", LANG_PLAYER, "PRINT_ALL", name, message) | ||
260 : | |||
261 : | log_amx("Chat: ^"%s<%d><%s><>^" say ^"%s^"", name, userid, authid, message) | ||
262 : | log_message("^"%s<%d><%s><>^" triggered ^"amx_say^" (text ^"%s^")", name, userid, authid, message) | ||
263 : | |||
264 : | return PLUGIN_HANDLED | ||
265 : | } | ||
266 : | |||
267 : | public cmdPsay(id, level, cid) | ||
268 : | { | ||
269 : | if (!cmd_access(id, level, cid, 3)) | ||
270 : | return PLUGIN_HANDLED | ||
271 : | |||
272 : | new name[32] | ||
273 : | read_argv(1, name, 31) | ||
274 : | new priv = cmd_target(id, name, 0) | ||
275 : | |||
276 : | if (!priv) | ||
277 : | return PLUGIN_HANDLED | ||
278 : | |||
279 : | ian | 17 | new length = strlen(name) + 1 |
280 : | |||
281 : | ian | 1 | get_user_name(priv, name, 31); |
282 : | |||
283 : | new message[192], name2[32], authid[32], authid2[32], userid, userid2 | ||
284 : | |||
285 : | get_user_authid(id, authid, 31) | ||
286 : | get_user_name(id, name2, 31) | ||
287 : | userid = get_user_userid(id) | ||
288 : | read_args(message, 191) | ||
289 : | |||
290 : | if (message[0] == '"' && message[length] == '"') // HLSW fix | ||
291 : | { | ||
292 : | message[0] = ' ' | ||
293 : | message[length] = ' ' | ||
294 : | length += 2 | ||
295 : | } | ||
296 : | |||
297 : | remove_quotes(message[length]) | ||
298 : | get_user_name(priv, name, 31) | ||
299 : | |||
300 : | if (id && id != priv) | ||
301 : | client_print(id, print_chat, "(%s) %s : %s", name, name2, message[length]) | ||
302 : | |||
303 : | client_print(priv, print_chat, "(%s) %s : %s", name, name2, message[length]) | ||
304 : | console_print(id, "(%s) %s : %s", name, name2, message[length]) | ||
305 : | get_user_authid(priv, authid2, 31) | ||
306 : | userid2 = get_user_userid(priv) | ||
307 : | |||
308 : | log_amx("Chat: ^"%s<%d><%s><>^" psay ^"%s<%d><%s><>^" ^"%s^"", name2, userid, authid, name, userid2, authid2, message[length]) | ||
309 : | log_message("^"%s<%d><%s><>^" triggered ^"amx_psay^" against ^"%s<%d><%s><>^" (text ^"%s^")", name2, userid, authid, name, userid2, authid2, message[length]) | ||
310 : | |||
311 : | return PLUGIN_HANDLED | ||
312 : | } | ||
313 : | |||
314 : | public cmdTsay(id, level, cid) | ||
315 : | { | ||
316 : | if (!cmd_access(id, level, cid, 3)) | ||
317 : | return PLUGIN_HANDLED | ||
318 : | |||
319 : | new cmd[16], color[16], color2[16], message[192], name[32], authid[32], userid = 0 | ||
320 : | |||
321 : | read_argv(0, cmd, 15) | ||
322 : | new bool:tsay = (tolower(cmd[4]) == 't') | ||
323 : | |||
324 : | read_args(message, 191) | ||
325 : | remove_quotes(message) | ||
326 : | parse(message, color, 15) | ||
327 : | |||
328 : | new found = 0, a = 0 | ||
329 : | new lang[3], langnum = get_langsnum() | ||
330 : | |||
331 : | for (new i = 0; i < MAX_CLR; ++i) | ||
332 : | { | ||
333 : | for (new j = 0; j < langnum; j++) | ||
334 : | { | ||
335 : | get_lang(j, lang) | ||
336 : | format(color2, 15, "%L", lang, g_Colors[i]) | ||
337 : | |||
338 : | if (equali(color, color2)) | ||
339 : | { | ||
340 : | a = i | ||
341 : | found = 1 | ||
342 : | break | ||
343 : | } | ||
344 : | } | ||
345 : | if (found == 1) | ||
346 : | break | ||
347 : | } | ||
348 : | |||
349 : | new length = found ? (strlen(color) + 1) : 0 | ||
350 : | |||
351 : | if (++g_msgChannel > 6 || g_msgChannel < 3) | ||
352 : | g_msgChannel = 3 | ||
353 : | |||
354 : | new Float:verpos = (tsay ? 0.55 : 0.1) + float(g_msgChannel) / 35.0 | ||
355 : | |||
356 : | get_user_authid(id, authid, 31) | ||
357 : | get_user_name(id, name, 31) | ||
358 : | userid = get_user_userid(id) | ||
359 : | set_hudmessage(g_Values[a][0], g_Values[a][1], g_Values[a][2], tsay ? 0.05 : -1.0, verpos, 0, 6.0, 6.0, 0.5, 0.15, -1) | ||
360 : | |||
361 : | ian | 17 | switch ( get_pcvar_num(amx_show_activity) ) |
362 : | ian | 1 | { |
363 : | ian | 17 | case 3, 4: |
364 : | { | ||
365 : | new maxpl = get_maxplayers(); | ||
366 : | for (new pl = 1; pl <= maxpl; pl++) | ||
367 : | { | ||
368 : | if (is_user_connected(pl) && !is_user_bot(pl)) | ||
369 : | { | ||
370 : | if (is_user_admin(pl)) | ||
371 : | { | ||
372 : | show_hudmessage(pl, "%s : %s", name, message[length]) | ||
373 : | client_print(pl, print_notify, "%s : %s", name, message[length]) | ||
374 : | } | ||
375 : | else | ||
376 : | { | ||
377 : | show_hudmessage(pl, "%s", message[length]) | ||
378 : | client_print(pl, print_notify, "%s", message[length]) | ||
379 : | } | ||
380 : | } | ||
381 : | } | ||
382 : | console_print(id, "%s : %s", name, message[length]) | ||
383 : | } | ||
384 : | case 2: | ||
385 : | { | ||
386 : | show_hudmessage(0, "%s : %s", name, message[length]) | ||
387 : | client_print(0, print_notify, "%s : %s", name, message[length]) | ||
388 : | console_print(id, "%s : %s", name, message[length]) | ||
389 : | } | ||
390 : | default: | ||
391 : | { | ||
392 : | show_hudmessage(0, "%s", message[length]) | ||
393 : | client_print(0, print_notify, "%s", message[length]) | ||
394 : | console_print(id, "%s", message[length]) | ||
395 : | } | ||
396 : | ian | 1 | } |
397 : | |||
398 : | log_amx("Chat: ^"%s<%d><%s><>^" %s ^"%s^"", name, userid, authid, cmd[4], message[length]) | ||
399 : | log_message("^"%s<%d><%s><>^" triggered ^"%s^" (text ^"%s^") (color ^"%s^")", name, userid, authid, cmd, message[length], color2) | ||
400 : | |||
401 : | return PLUGIN_HANDLED | ||
402 : | } |
Contact | ViewVC Help |
Powered by ViewVC 1.0.4 |