Fixed gamedata file refcounting bug in the structs extension.
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:", "Choose Type", 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)
215 g_Muted[target] = true;
216 SetClientListeningFlags(target, VOICE_MUTED);
217 LogAction(client, target, "\"%L\" muted \"%L\"", client, target);
220 PerformUnMute(client, target)
222 g_Muted[target] = false;
223 if (GetConVarInt(g_Cvar_Deadtalk) == 1 && !IsPlayerAlive(target))
225 SetClientListeningFlags(target, VOICE_LISTENALL);
227 else if (GetConVarInt(g_Cvar_Deadtalk) == 2 && !IsPlayerAlive(target))
229 SetClientListeningFlags(target, VOICE_TEAM);
233 SetClientListeningFlags(target, VOICE_NORMAL);
236 LogAction(client, target, "\"%L\" unmuted \"%L\"", client, target);
239 PerformGag(client, target)
241 g_Gagged[target] = true;
242 LogAction(client, target, "\"%L\" gagged \"%L\"", client, target);
245 PerformUnGag(client, target)
247 g_Gagged[target] = false;
248 LogAction(client, target, "\"%L\" ungagged \"%L\"", client, target);
251 PerformSilence(client, target)
253 if (!g_Gagged[target])
255 g_Gagged[target] = true;
258 if (!g_Muted[target])
260 g_Muted[target] = true;
261 SetClientListeningFlags(target, VOICE_MUTED);
264 LogAction(client, target, "\"%L\" silenced \"%L\"", client, target);
267 PerformUnSilence(client, target)
269 if (g_Gagged[target])
271 g_Gagged[target] = false;
276 g_Muted[target] = false;
278 if (GetConVarInt(g_Cvar_Deadtalk) == 1 && !IsPlayerAlive(target))
280 SetClientListeningFlags(target, VOICE_LISTENALL);
282 else if (GetConVarInt(g_Cvar_Deadtalk) == 2 && !IsPlayerAlive(target))
284 SetClientListeningFlags(target, VOICE_TEAM);
288 SetClientListeningFlags(target, VOICE_NORMAL);
292 LogAction(client, target, "\"%L\" unsilenced \"%L\"", client, target);
295 public Action:Command_Mute(client, args)
299 ReplyToCommand(client, "[SM] Usage: sm_mute <player>");
300 return Plugin_Handled;
304 GetCmdArg(1, arg, sizeof(arg));
306 decl String:target_name[MAX_TARGET_LENGTH];
307 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
309 if ((target_count = ProcessTargetString(
319 ReplyToTargetError(client, target_count);
320 return Plugin_Handled;
323 for (new i = 0; i < target_count; i++)
325 new target = target_list[i];
327 PerformMute(client, target);
332 ShowActivity2(client, "[SM] ", "%t", "Muted target", target_name);
336 ShowActivity2(client, "[SM] ", "%t", "Muted target", "_s", target_name);
339 return Plugin_Handled;
342 public Action:Command_Gag(client, args)
346 ReplyToCommand(client, "[SM] Usage: sm_gag <player>");
347 return Plugin_Handled;
351 GetCmdArg(1, arg, sizeof(arg));
353 decl String:target_name[MAX_TARGET_LENGTH];
354 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
356 if ((target_count = ProcessTargetString(
366 ReplyToTargetError(client, target_count);
367 return Plugin_Handled;
370 for (new i = 0; i < target_count; i++)
372 new target = target_list[i];
374 PerformGag(client, target);
379 ShowActivity2(client, "[SM] ", "%t", "Gagged target", target_name);
383 ShowActivity2(client, "[SM] ", "%t", "Gagged target", "_s", target_name);
386 return Plugin_Handled;
389 public Action:Command_Silence(client, args)
393 ReplyToCommand(client, "[SM] Usage: sm_silence <player>");
394 return Plugin_Handled;
398 GetCmdArg(1, arg, sizeof(arg));
400 decl String:target_name[MAX_TARGET_LENGTH];
401 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
403 if ((target_count = ProcessTargetString(
413 ReplyToTargetError(client, target_count);
414 return Plugin_Handled;
417 for (new i = 0; i < target_count; i++)
419 new target = target_list[i];
421 PerformSilence(client, target);
426 ShowActivity2(client, "[SM] ", "%t", "Silenced target", target_name);
430 ShowActivity2(client, "[SM] ", "%t", "Silenced target", "_s", target_name);
433 return Plugin_Handled;
436 public Action:Command_Unmute(client, args)
440 ReplyToCommand(client, "[SM] Usage: sm_unmute <player>");
441 return Plugin_Handled;
445 GetCmdArg(1, arg, sizeof(arg));
447 decl String:target_name[MAX_TARGET_LENGTH];
448 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
450 if ((target_count = ProcessTargetString(
460 ReplyToTargetError(client, target_count);
461 return Plugin_Handled;
464 for (new i = 0; i < target_count; i++)
466 new target = target_list[i];
468 if (!g_Muted[target])
473 PerformUnMute(client, target);
478 ShowActivity2(client, "[SM] ", "%t", "Unmuted target", target_name);
482 ShowActivity2(client, "[SM] ", "%t", "Unmuted target", "_s", target_name);
485 return Plugin_Handled;
488 public Action:Command_Ungag(client, args)
492 ReplyToCommand(client, "[SM] Usage: sm_ungag <player>");
493 return Plugin_Handled;
497 GetCmdArg(1, arg, sizeof(arg));
499 decl String:target_name[MAX_TARGET_LENGTH];
500 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
502 if ((target_count = ProcessTargetString(
512 ReplyToTargetError(client, target_count);
513 return Plugin_Handled;
516 for (new i = 0; i < target_count; i++)
518 new target = target_list[i];
520 PerformUnGag(client, target);
525 ShowActivity2(client, "[SM] ", "%t", "Ungagged target", target_name);
529 ShowActivity2(client, "[SM] ", "%t", "Ungagged target", "_s", target_name);
532 return Plugin_Handled;
535 public Action:Command_Unsilence(client, args)
539 ReplyToCommand(client, "[SM] Usage: sm_unsilence <player>");
540 return Plugin_Handled;
544 GetCmdArg(1, arg, sizeof(arg));
546 decl String:target_name[MAX_TARGET_LENGTH];
547 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
549 if ((target_count = ProcessTargetString(
559 ReplyToTargetError(client, target_count);
560 return Plugin_Handled;
563 for (new i = 0; i < target_count; i++)
565 new target = target_list[i];
567 PerformUnSilence(client, target);
572 ShowActivity2(client, "[SM] ", "%t", "Unsilenced target", target_name);
576 ShowActivity2(client, "[SM] ", "%t", "Unsilenced target", "_s", target_name);
579 return Plugin_Handled;