3 * =============================================================================
4 * SourceMod Basefuncommands Plugin
5 * Provides noclip 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>.
34 PerformNoClip(client, target)
36 new MoveType:movetype = GetEntityMoveType(target);
38 if (movetype != MOVETYPE_NOCLIP)
40 SetEntityMoveType(target, MOVETYPE_NOCLIP);
44 SetEntityMoveType(target, MOVETYPE_WALK);
47 LogAction(client, target, "\"%L\" toggled noclip on \"%L\"", client, target);
50 public AdminMenu_NoClip(Handle:topmenu,
52 TopMenuObject:object_id,
57 if (action == TopMenuAction_DisplayOption)
59 Format(buffer, maxlength, "%T", "NoClip player", param);
61 else if (action == TopMenuAction_SelectOption)
63 DisplayNoClipMenu(param);
67 DisplayNoClipMenu(client)
69 new Handle:menu = CreateMenu(MenuHandler_NoClip);
71 decl String:title[100];
72 Format(title, sizeof(title), "%T:", "NoClip player", client);
73 SetMenuTitle(menu, title);
74 SetMenuExitBackButton(menu, true);
76 AddTargetsToMenu(menu, client, true, true);
78 DisplayMenu(menu, client, MENU_TIME_FOREVER);
81 public MenuHandler_NoClip(Handle:menu, MenuAction:action, param1, param2)
83 if (action == MenuAction_End)
87 else if (action == MenuAction_Cancel)
89 if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
91 DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
94 else if (action == MenuAction_Select)
99 GetMenuItem(menu, param2, info, sizeof(info));
100 userid = StringToInt(info);
102 if ((target = GetClientOfUserId(userid)) == 0)
104 PrintToChat(param1, "[SM] %t", "Player no longer available");
106 else if (!CanUserTarget(param1, target))
108 PrintToChat(param1, "[SM] %t", "Unable to target");
113 GetClientName(target, name, sizeof(name));
115 PerformNoClip(param1, target);
116 ShowActivity2(param1, "[SM] ", "%t", "Toggled noclip on target", "_s", name);
119 /* Re-draw the menu if they're still valid */
120 if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
122 DisplayNoClipMenu(param1);
127 public Action:Command_NoClip(client, args)
131 ReplyToCommand(client, "[SM] Usage: sm_noclip <#userid|name>");
132 return Plugin_Handled;
136 GetCmdArg(1, arg, sizeof(arg));
138 decl String:target_name[MAX_TARGET_LENGTH];
139 decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
141 if ((target_count = ProcessTargetString(
146 COMMAND_FILTER_ALIVE,
151 ReplyToTargetError(client, target_count);
152 return Plugin_Handled;
155 for (new i = 0; i < target_count; i++)
157 PerformNoClip(client, target_list[i]);
162 ShowActivity2(client, "[SM] ", "%t", "Toggled noclip on target", target_name);
166 ShowActivity2(client, "[SM] ", "%t", "Toggled noclip on target", "_s", target_name);
169 return Plugin_Handled;