3 * =============================================================================
5 * Part of Basecomm plugin, menu and other functionality.
7 * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
8 * =============================================================================
10 * This program is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License, version 3.0, as published by the
12 * Free Software Foundation.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 * You should have received a copy of the GNU General Public License along with
20 * this program. If not, see <http://www.gnu.org/licenses/>.
22 * As a special exception, AlliedModders LLC gives you permission to link the
23 * code of this program (as well as its derivative works) to "Half-Life 2," the
24 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
25 * by the Valve Corporation. You must obey the GNU General Public License in
26 * all respects for all other code used. Additionally, AlliedModders LLC grants
27 * this exception to all derivative works. AlliedModders LLC defines further
28 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
29 * or <http://www.sourcemod.net/license.php>.
44 DisplayGagTypesMenu(client)
46 new Handle:menu = CreateMenu(MenuHandler_GagTypes);
48 decl String:title[100];
49 Format(title, sizeof(title), "%T: %N", "Choose Type", client, g_GagTarget[client]);
50 SetMenuTitle(menu, title);
51 SetMenuExitBackButton(menu, true);
53 new target = g_GagTarget[client];
57 AddMenuItem(menu, "0", "Mute Player");
61 AddMenuItem(menu, "1", "UnMute Player");
64 if (!g_Gagged[target])
66 AddMenuItem(menu, "2", "Gag Player");
70 AddMenuItem(menu, "3", "UnGag Player");
73 if (!g_Muted[target] || !g_Gagged[target])
75 AddMenuItem(menu, "4", "Silence Player");
79 AddMenuItem(menu, "5", "UnSilence Player");
82 DisplayMenu(menu, client, MENU_TIME_FOREVER);
85 DisplayGagPlayerMenu(client)
87 new Handle:menu = CreateMenu(MenuHandler_GagPlayer);
89 decl String:title[100];
90 Format(title, sizeof(title), "%T:", "Gag/Mute player", client);
91 SetMenuTitle(menu, title);
92 SetMenuExitBackButton(menu, true);
94 AddTargetsToMenu(menu, client, true, false);
96 DisplayMenu(menu, client, MENU_TIME_FOREVER);
99 public AdminMenu_Gag(Handle:topmenu,
100 TopMenuAction:action,
101 TopMenuObject:object_id,
106 if (action == TopMenuAction_DisplayOption)
108 Format(buffer, maxlength, "%T", "Gag/Mute player", param);
110 else if (action == TopMenuAction_SelectOption)
112 DisplayGagPlayerMenu(param);
116 public MenuHandler_GagPlayer(Handle:menu, MenuAction:action, param1, param2)
118 if (action == MenuAction_End)
122 else if (action == MenuAction_Cancel)
124 if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
126 DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
129 else if (action == MenuAction_Select)
131 decl String:info[32];
134 GetMenuItem(menu, param2, info, sizeof(info));
135 userid = StringToInt(info);
137 if ((target = GetClientOfUserId(userid)) == 0)
139 PrintToChat(param1, "[SM] %t", "Player no longer available");
141 else if (!CanUserTarget(param1, target))
143 PrintToChat(param1, "[SM] %t", "Unable to target");
147 g_GagTarget[param1] = GetClientOfUserId(userid);
148 DisplayGagTypesMenu(param1);
153 public MenuHandler_GagTypes(Handle:menu, MenuAction:action, param1, param2)
155 if (action == MenuAction_End)
159 else if (action == MenuAction_Cancel)
161 if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
163 DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
166 else if (action == MenuAction_Select)
168 decl String:info[32];
171 GetMenuItem(menu, param2, info, sizeof(info));
172 type = CommType:StringToInt(info);
174 decl String:name[MAX_NAME_LENGTH];
175 GetClientName(g_GagTarget[param1], name, sizeof(name));
181 PerformMute(param1, g_GagTarget[param1]);
182 ShowActivity2(param1, "[SM] ", "%t", "Muted target", "_s", name);
184 case CommType_UnMute:
186 PerformUnMute(param1, g_GagTarget[param1]);
187 ShowActivity2(param1, "[SM] ", "%t", "Unmuted target", "_s", name);
191 PerformGag(param1, g_GagTarget[param1]);
192 ShowActivity2(param1, "[SM] ", "%t", "Gagged target", "_s", name);
196 PerformUnGag(param1, g_GagTarget[param1]);
197 ShowActivity2(param1, "[SM] ", "%t", "Ungagged target", "_s", name);
199 case CommType_Silence:
201 PerformSilence(param1, g_GagTarget[param1]);
202 ShowActivity2(param1, "[SM] ", "%t", "Silenced target", "_s", name);
204 case CommType_UnSilence:
206 PerformUnSilence(param1, g_GagTarget[param1]);
207 ShowActivity2(param1, "[SM] ", "%t", "Unsilenced target", "_s", name);
213 PerformMute(client, target, bool:silent=false)
215 g_Muted[target] = true;
216 SetClientListeningFlags(target, VOICE_MUTED);
220 LogAction(client, target, "\"%L\" muted \"%L\"", client, target);
224 PerformUnMute(client, target, bool:silent=false)
226 g_Muted[target] = false;
227 if (GetConVarInt(g_Cvar_Deadtalk) == 1 && !IsPlayerAlive(target))
229 SetClientListeningFlags(target, VOICE_LISTENALL);
231 else if (GetConVarInt(g_Cvar_Deadtalk) == 2 && !IsPlayerAlive(target))
233 SetClientListeningFlags(target, VOICE_TEAM);
237 SetClientListeningFlags(target, VOICE_NORMAL);
242 LogAction(client, target, "\"%L\" unmuted \"%L\"", client, target);
246 PerformGag(client, target, bool:silent=false)
248 g_Gagged[target] = true;
252 LogAction(client, target, "\"%L\" gagged \"%L\"", client, target);
256 PerformUnGag(client, target, bool:silent=false)
258 g_Gagged[target] = false;
262 LogAction(client, target, "\"%L\" ungagged \"%L\"", client, target);
266 PerformSilence(client, target)
268 if (!g_Gagged[target])
270 g_Gagged[target] = true;
273 if (!g_Muted[target])
275 g_Muted[target] = true;
276 SetClientListeningFlags(target, VOICE_MUTED);
279 LogAction(client, target, "\"%L\" silenced \"%L\"", client, target);
282 PerformUnSilence(client, target)
284 if (g_Gagged[target])
286 g_Gagged[target] = false;
291 g_Muted[target] = false;
293 if (GetConVarInt(g_Cvar_Deadtalk) == 1 && !IsPlayerAlive(target))
295 SetClientListeningFlags(target, VOICE_LISTENALL);
297 else if (GetConVarInt(g_Cvar_Deadtalk) == 2 && !IsPlayerAlive(target))
299 SetClientListeningFlags(target, VOICE_TEAM);
303 SetClientListeningFlags(target, VOICE_NORMAL);
307 LogAction(client, target, "\"%L\" unsilenced \"%L\"", client, target);
310 public Action:Command_Mute(client, args)
314 ReplyToCommand(client, "[SM] Usage: sm_mute <player>");
315 return Plugin_Handled;
319 GetCmdArg(1, arg, sizeof(arg));
321 decl String:target_name[MAX_TARGET_LENGTH];
322 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
324 if ((target_count = ProcessTargetString(
334 ReplyToTargetError(client, target_count);
335 return Plugin_Handled;
338 for (new i = 0; i < target_count; i++)
340 new target = target_list[i];
342 PerformMute(client, target);
347 ShowActivity2(client, "[SM] ", "%t", "Muted target", target_name);
351 ShowActivity2(client, "[SM] ", "%t", "Muted target", "_s", target_name);
354 return Plugin_Handled;
357 public Action:Command_Gag(client, args)
361 ReplyToCommand(client, "[SM] Usage: sm_gag <player>");
362 return Plugin_Handled;
366 GetCmdArg(1, arg, sizeof(arg));
368 decl String:target_name[MAX_TARGET_LENGTH];
369 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
371 if ((target_count = ProcessTargetString(
381 ReplyToTargetError(client, target_count);
382 return Plugin_Handled;
385 for (new i = 0; i < target_count; i++)
387 new target = target_list[i];
389 PerformGag(client, target);
394 ShowActivity2(client, "[SM] ", "%t", "Gagged target", target_name);
398 ShowActivity2(client, "[SM] ", "%t", "Gagged target", "_s", target_name);
401 return Plugin_Handled;
404 public Action:Command_Silence(client, args)
408 ReplyToCommand(client, "[SM] Usage: sm_silence <player>");
409 return Plugin_Handled;
413 GetCmdArg(1, arg, sizeof(arg));
415 decl String:target_name[MAX_TARGET_LENGTH];
416 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
418 if ((target_count = ProcessTargetString(
428 ReplyToTargetError(client, target_count);
429 return Plugin_Handled;
432 for (new i = 0; i < target_count; i++)
434 new target = target_list[i];
436 PerformSilence(client, target);
441 ShowActivity2(client, "[SM] ", "%t", "Silenced target", target_name);
445 ShowActivity2(client, "[SM] ", "%t", "Silenced target", "_s", target_name);
448 return Plugin_Handled;
451 public Action:Command_Unmute(client, args)
455 ReplyToCommand(client, "[SM] Usage: sm_unmute <player>");
456 return Plugin_Handled;
460 GetCmdArg(1, arg, sizeof(arg));
462 decl String:target_name[MAX_TARGET_LENGTH];
463 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
465 if ((target_count = ProcessTargetString(
475 ReplyToTargetError(client, target_count);
476 return Plugin_Handled;
479 for (new i = 0; i < target_count; i++)
481 new target = target_list[i];
483 if (!g_Muted[target])
488 PerformUnMute(client, target);
493 ShowActivity2(client, "[SM] ", "%t", "Unmuted target", target_name);
497 ShowActivity2(client, "[SM] ", "%t", "Unmuted target", "_s", target_name);
500 return Plugin_Handled;
503 public Action:Command_Ungag(client, args)
507 ReplyToCommand(client, "[SM] Usage: sm_ungag <player>");
508 return Plugin_Handled;
512 GetCmdArg(1, arg, sizeof(arg));
514 decl String:target_name[MAX_TARGET_LENGTH];
515 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
517 if ((target_count = ProcessTargetString(
527 ReplyToTargetError(client, target_count);
528 return Plugin_Handled;
531 for (new i = 0; i < target_count; i++)
533 new target = target_list[i];
535 PerformUnGag(client, target);
540 ShowActivity2(client, "[SM] ", "%t", "Ungagged target", target_name);
544 ShowActivity2(client, "[SM] ", "%t", "Ungagged target", "_s", target_name);
547 return Plugin_Handled;
550 public Action:Command_Unsilence(client, args)
554 ReplyToCommand(client, "[SM] Usage: sm_unsilence <player>");
555 return Plugin_Handled;
559 GetCmdArg(1, arg, sizeof(arg));
561 decl String:target_name[MAX_TARGET_LENGTH];
562 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
564 if ((target_count = ProcessTargetString(
574 ReplyToTargetError(client, target_count);
575 return Plugin_Handled;
578 for (new i = 0; i < target_count; i++)
580 new target = target_list[i];
582 PerformUnSilence(client, target);
587 ShowActivity2(client, "[SM] ", "%t", "Unsilenced target", target_name);
591 ShowActivity2(client, "[SM] ", "%t", "Unsilenced target", "_s", target_name);
594 return Plugin_Handled;