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 AddTranslatedMenuItem(menu, "0", "Mute Player", client);
61 AddTranslatedMenuItem(menu, "1", "UnMute Player", client);
64 if (!g_Gagged[target])
66 AddTranslatedMenuItem(menu, "2", "Gag Player", client);
70 AddTranslatedMenuItem(menu, "3", "UnGag Player", client);
73 if (!g_Muted[target] || !g_Gagged[target])
75 AddTranslatedMenuItem(menu, "4", "Silence Player", client);
79 AddTranslatedMenuItem(menu, "5", "UnSilence Player", client);
82 DisplayMenu(menu, client, MENU_TIME_FOREVER);
85 AddTranslatedMenuItem(Handle:menu, const String:opt[], const String:phrase[], client)
87 decl String:buffer[128];
88 Format(buffer, sizeof(buffer), "%T", phrase, client);
89 AddMenuItem(menu, opt, buffer);
92 DisplayGagPlayerMenu(client)
94 new Handle:menu = CreateMenu(MenuHandler_GagPlayer);
96 decl String:title[100];
97 Format(title, sizeof(title), "%T:", "Gag/Mute player", client);
98 SetMenuTitle(menu, title);
99 SetMenuExitBackButton(menu, true);
101 AddTargetsToMenu(menu, client, true, false);
103 DisplayMenu(menu, client, MENU_TIME_FOREVER);
106 public AdminMenu_Gag(Handle:topmenu,
107 TopMenuAction:action,
108 TopMenuObject:object_id,
113 if (action == TopMenuAction_DisplayOption)
115 Format(buffer, maxlength, "%T", "Gag/Mute player", param);
117 else if (action == TopMenuAction_SelectOption)
119 DisplayGagPlayerMenu(param);
123 public MenuHandler_GagPlayer(Handle:menu, MenuAction:action, param1, param2)
125 if (action == MenuAction_End)
129 else if (action == MenuAction_Cancel)
131 if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
133 DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
136 else if (action == MenuAction_Select)
138 decl String:info[32];
141 GetMenuItem(menu, param2, info, sizeof(info));
142 userid = StringToInt(info);
144 if ((target = GetClientOfUserId(userid)) == 0)
146 PrintToChat(param1, "[SM] %t", "Player no longer available");
148 else if (!CanUserTarget(param1, target))
150 PrintToChat(param1, "[SM] %t", "Unable to target");
154 g_GagTarget[param1] = GetClientOfUserId(userid);
155 DisplayGagTypesMenu(param1);
160 public MenuHandler_GagTypes(Handle:menu, MenuAction:action, param1, param2)
162 if (action == MenuAction_End)
166 else if (action == MenuAction_Cancel)
168 if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
170 DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
173 else if (action == MenuAction_Select)
175 decl String:info[32];
178 GetMenuItem(menu, param2, info, sizeof(info));
179 type = CommType:StringToInt(info);
181 decl String:name[MAX_NAME_LENGTH];
182 GetClientName(g_GagTarget[param1], name, sizeof(name));
188 PerformMute(param1, g_GagTarget[param1]);
189 ShowActivity2(param1, "[SM] ", "%t", "Muted target", "_s", name);
191 case CommType_UnMute:
193 PerformUnMute(param1, g_GagTarget[param1]);
194 ShowActivity2(param1, "[SM] ", "%t", "Unmuted target", "_s", name);
198 PerformGag(param1, g_GagTarget[param1]);
199 ShowActivity2(param1, "[SM] ", "%t", "Gagged target", "_s", name);
203 PerformUnGag(param1, g_GagTarget[param1]);
204 ShowActivity2(param1, "[SM] ", "%t", "Ungagged target", "_s", name);
206 case CommType_Silence:
208 PerformSilence(param1, g_GagTarget[param1]);
209 ShowActivity2(param1, "[SM] ", "%t", "Silenced target", "_s", name);
211 case CommType_UnSilence:
213 PerformUnSilence(param1, g_GagTarget[param1]);
214 ShowActivity2(param1, "[SM] ", "%t", "Unsilenced target", "_s", name);
220 PerformMute(client, target, bool:silent=false)
222 g_Muted[target] = true;
223 SetClientListeningFlags(target, VOICE_MUTED);
225 FireOnClientMute(target, true);
229 LogAction(client, target, "\"%L\" muted \"%L\"", client, target);
233 PerformUnMute(client, target, bool:silent=false)
235 g_Muted[target] = false;
236 if (GetConVarInt(g_Cvar_Deadtalk) == 1 && !IsPlayerAlive(target))
238 SetClientListeningFlags(target, VOICE_LISTENALL);
240 else if (GetConVarInt(g_Cvar_Deadtalk) == 2 && !IsPlayerAlive(target))
242 SetClientListeningFlags(target, VOICE_TEAM);
246 SetClientListeningFlags(target, VOICE_NORMAL);
249 FireOnClientMute(target, false);
253 LogAction(client, target, "\"%L\" unmuted \"%L\"", client, target);
257 PerformGag(client, target, bool:silent=false)
259 g_Gagged[target] = true;
260 FireOnClientGag(target, true);
264 LogAction(client, target, "\"%L\" gagged \"%L\"", client, target);
268 PerformUnGag(client, target, bool:silent=false)
270 g_Gagged[target] = false;
271 FireOnClientGag(target, false);
275 LogAction(client, target, "\"%L\" ungagged \"%L\"", client, target);
279 PerformSilence(client, target)
281 if (!g_Gagged[target])
283 g_Gagged[target] = true;
284 FireOnClientGag(target, true);
287 if (!g_Muted[target])
289 g_Muted[target] = true;
290 SetClientListeningFlags(target, VOICE_MUTED);
291 FireOnClientMute(target, true);
294 LogAction(client, target, "\"%L\" silenced \"%L\"", client, target);
297 PerformUnSilence(client, target)
299 if (g_Gagged[target])
301 g_Gagged[target] = false;
302 FireOnClientGag(target, false);
307 g_Muted[target] = false;
309 if (GetConVarInt(g_Cvar_Deadtalk) == 1 && !IsPlayerAlive(target))
311 SetClientListeningFlags(target, VOICE_LISTENALL);
313 else if (GetConVarInt(g_Cvar_Deadtalk) == 2 && !IsPlayerAlive(target))
315 SetClientListeningFlags(target, VOICE_TEAM);
319 SetClientListeningFlags(target, VOICE_NORMAL);
321 FireOnClientMute(target, false);
324 LogAction(client, target, "\"%L\" unsilenced \"%L\"", client, target);
327 public Action:Command_Mute(client, args)
331 ReplyToCommand(client, "[SM] Usage: sm_mute <player>");
332 return Plugin_Handled;
336 GetCmdArg(1, arg, sizeof(arg));
338 decl String:target_name[MAX_TARGET_LENGTH];
339 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
341 if ((target_count = ProcessTargetString(
351 ReplyToTargetError(client, target_count);
352 return Plugin_Handled;
355 for (new i = 0; i < target_count; i++)
357 new target = target_list[i];
359 PerformMute(client, target);
364 ShowActivity2(client, "[SM] ", "%t", "Muted target", target_name);
368 ShowActivity2(client, "[SM] ", "%t", "Muted target", "_s", target_name);
371 return Plugin_Handled;
374 public Action:Command_Gag(client, args)
378 ReplyToCommand(client, "[SM] Usage: sm_gag <player>");
379 return Plugin_Handled;
383 GetCmdArg(1, arg, sizeof(arg));
385 decl String:target_name[MAX_TARGET_LENGTH];
386 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
388 if ((target_count = ProcessTargetString(
398 ReplyToTargetError(client, target_count);
399 return Plugin_Handled;
402 for (new i = 0; i < target_count; i++)
404 new target = target_list[i];
406 PerformGag(client, target);
411 ShowActivity2(client, "[SM] ", "%t", "Gagged target", target_name);
415 ShowActivity2(client, "[SM] ", "%t", "Gagged target", "_s", target_name);
418 return Plugin_Handled;
421 public Action:Command_Silence(client, args)
425 ReplyToCommand(client, "[SM] Usage: sm_silence <player>");
426 return Plugin_Handled;
430 GetCmdArg(1, arg, sizeof(arg));
432 decl String:target_name[MAX_TARGET_LENGTH];
433 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
435 if ((target_count = ProcessTargetString(
445 ReplyToTargetError(client, target_count);
446 return Plugin_Handled;
449 for (new i = 0; i < target_count; i++)
451 new target = target_list[i];
453 PerformSilence(client, target);
458 ShowActivity2(client, "[SM] ", "%t", "Silenced target", target_name);
462 ShowActivity2(client, "[SM] ", "%t", "Silenced target", "_s", target_name);
465 return Plugin_Handled;
468 public Action:Command_Unmute(client, args)
472 ReplyToCommand(client, "[SM] Usage: sm_unmute <player>");
473 return Plugin_Handled;
477 GetCmdArg(1, arg, sizeof(arg));
479 decl String:target_name[MAX_TARGET_LENGTH];
480 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
482 if ((target_count = ProcessTargetString(
492 ReplyToTargetError(client, target_count);
493 return Plugin_Handled;
496 for (new i = 0; i < target_count; i++)
498 new target = target_list[i];
500 if (!g_Muted[target])
505 PerformUnMute(client, target);
510 ShowActivity2(client, "[SM] ", "%t", "Unmuted target", target_name);
514 ShowActivity2(client, "[SM] ", "%t", "Unmuted target", "_s", target_name);
517 return Plugin_Handled;
520 public Action:Command_Ungag(client, args)
524 ReplyToCommand(client, "[SM] Usage: sm_ungag <player>");
525 return Plugin_Handled;
529 GetCmdArg(1, arg, sizeof(arg));
531 decl String:target_name[MAX_TARGET_LENGTH];
532 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
534 if ((target_count = ProcessTargetString(
544 ReplyToTargetError(client, target_count);
545 return Plugin_Handled;
548 for (new i = 0; i < target_count; i++)
550 new target = target_list[i];
552 PerformUnGag(client, target);
557 ShowActivity2(client, "[SM] ", "%t", "Ungagged target", target_name);
561 ShowActivity2(client, "[SM] ", "%t", "Ungagged target", "_s", target_name);
564 return Plugin_Handled;
567 public Action:Command_Unsilence(client, args)
571 ReplyToCommand(client, "[SM] Usage: sm_unsilence <player>");
572 return Plugin_Handled;
576 GetCmdArg(1, arg, sizeof(arg));
578 decl String:target_name[MAX_TARGET_LENGTH];
579 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
581 if ((target_count = ProcessTargetString(
591 ReplyToTargetError(client, target_count);
592 return Plugin_Handled;
595 for (new i = 0; i < target_count; i++)
597 new target = target_list[i];
599 PerformUnSilence(client, target);
604 ShowActivity2(client, "[SM] ", "%t", "Unsilenced target", target_name);
608 ShowActivity2(client, "[SM] ", "%t", "Unsilenced target", "_s", target_name);
611 return Plugin_Handled;