Fixed file headers on all base plugin includes.
3 * =============================================================================
4 * SourceMod Basefuncommands Plugin
5 * Provides slap functionality
7 * SourceMod (C)2004-2007 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>.
31 * Version: $Id: admin-flatfile.sp 1438 2007-09-16 03:45:06Z dvander $
34 PerformSlap(client, target, damage)
36 LogAction(client, target, "\"%L\" slapped \"%L\" (damage \"%d\")", client, target, damage);
37 SlapPlayer(target, damage, true);
40 DisplaySlapDamageMenu(client)
42 new Handle:menu = CreateMenu(MenuHandler_SlapDamage);
44 decl String:title[100];
45 Format(title, sizeof(title), "%T:", "Slap damage", client);
46 SetMenuTitle(menu, title);
47 SetMenuExitBackButton(menu, true);
49 AddMenuItem(menu, "0", "0");
50 AddMenuItem(menu, "1", "1");
51 AddMenuItem(menu, "5", "5");
52 AddMenuItem(menu, "10", "10");
53 AddMenuItem(menu, "20", "20");
54 AddMenuItem(menu, "50", "50");
55 AddMenuItem(menu, "99", "99");
57 DisplayMenu(menu, client, MENU_TIME_FOREVER);
60 DisplaySlapTargetMenu(client)
62 new Handle:menu = CreateMenu(MenuHandler_Slap);
64 decl String:title[100];
65 Format(title, sizeof(title), "%T:", "Slap player", client);
66 SetMenuTitle(menu, title);
67 SetMenuExitBackButton(menu, true);
69 AddTargetsToMenu(menu, client, true, true);
71 DisplayMenu(menu, client, MENU_TIME_FOREVER);
74 public AdminMenu_Slap(Handle:topmenu,
76 TopMenuObject:object_id,
81 if (action == TopMenuAction_DisplayOption)
83 Format(buffer, maxlength, "%T", "Slap player", param);
85 else if (action == TopMenuAction_SelectOption)
87 DisplaySlapDamageMenu(param);
91 public MenuHandler_SlapDamage(Handle:menu, MenuAction:action, param1, param2)
93 if (action == MenuAction_End)
97 else if (action == MenuAction_Cancel)
99 if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
101 DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
104 else if (action == MenuAction_Select)
106 decl String:info[32];
108 GetMenuItem(menu, param2, info, sizeof(info));
109 g_SlapDamage[param1] = StringToInt(info);
111 DisplaySlapTargetMenu(param1);
115 public MenuHandler_Slap(Handle:menu, MenuAction:action, param1, param2)
117 if (action == MenuAction_End)
121 else if (action == MenuAction_Cancel)
123 if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
125 DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
128 else if (action == MenuAction_Select)
130 decl String:info[32];
133 GetMenuItem(menu, param2, info, sizeof(info));
134 userid = StringToInt(info);
136 if ((target = GetClientOfUserId(userid)) == 0)
138 PrintToChat(param1, "[SM] %t", "Player no longer available");
140 else if (!CanUserTarget(param1, target))
142 PrintToChat(param1, "[SM] %t", "Unable to target");
144 else if (!IsPlayerAlive(target))
146 ReplyToCommand(param1, "[SM] %t", "Player has since died");
150 decl String:name[32];
151 GetClientName(target, name, sizeof(name));
152 PerformSlap(param1, target, g_SlapDamage[param1]);
153 ShowActivity2(param1, "[SM] ", "%t", "Slapped target", "_s", name);
156 DisplaySlapTargetMenu(param1);
160 public Action:Command_Slap(client, args)
164 ReplyToCommand(client, "[SM] Usage: sm_slap <#userid|name> [damage]");
165 return Plugin_Handled;
169 GetCmdArg(1, arg, sizeof(arg));
174 decl String:arg2[20];
175 GetCmdArg(2, arg2, sizeof(arg2));
176 if (StringToIntEx(arg2, damage) == 0)
178 ReplyToCommand(client, "[SM] %t", "Invalid Amount");
179 return Plugin_Handled;
183 decl String:target_name[MAX_TARGET_LENGTH];
184 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
186 if ((target_count = ProcessTargetString(
191 COMMAND_FILTER_ALIVE,
196 ReplyToTargetError(client, target_count);
197 return Plugin_Handled;
200 for (new i = 0; i < target_count; i++)
202 PerformSlap(client, target_list[i], damage);
207 ShowActivity2(client, "[SM] ", "%t", "Slapped target", target_name);
211 ShowActivity2(client, "[SM] ", "%t", "Slapped target", "_s", target_name);
214 return Plugin_Handled;