1.1 --- a/plugins/funcommands/noclip.sp Fri Jul 11 06:51:21 2008 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,175 +0,0 @@
1.4 -/**
1.5 - * vim: set ts=4 :
1.6 - * =============================================================================
1.7 - * SourceMod Basefuncommands Plugin
1.8 - * Provides noclip functionality
1.9 - *
1.10 - * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
1.11 - * =============================================================================
1.12 - *
1.13 - * This program is free software; you can redistribute it and/or modify it under
1.14 - * the terms of the GNU General Public License, version 3.0, as published by the
1.15 - * Free Software Foundation.
1.16 - *
1.17 - * This program is distributed in the hope that it will be useful, but WITHOUT
1.18 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.19 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1.20 - * details.
1.21 - *
1.22 - * You should have received a copy of the GNU General Public License along with
1.23 - * this program. If not, see <http://www.gnu.org/licenses/>.
1.24 - *
1.25 - * As a special exception, AlliedModders LLC gives you permission to link the
1.26 - * code of this program (as well as its derivative works) to "Half-Life 2," the
1.27 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
1.28 - * by the Valve Corporation. You must obey the GNU General Public License in
1.29 - * all respects for all other code used. Additionally, AlliedModders LLC grants
1.30 - * this exception to all derivative works. AlliedModders LLC defines further
1.31 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
1.32 - * or <http://www.sourcemod.net/license.php>.
1.33 - *
1.34 - * Version: $Id$
1.35 - */
1.36 -
1.37 -SetupNoClip()
1.38 -{
1.39 - RegAdminCmd("sm_noclip", Command_NoClip, ADMFLAG_SLAY|ADMFLAG_CHEATS, "sm_noclip <#userid|name>");
1.40 -}
1.41 -
1.42 -PerformNoClip(client, target)
1.43 -{
1.44 - new MoveType:movetype = GetEntityMoveType(target);
1.45 -
1.46 - if (movetype != MOVETYPE_NOCLIP)
1.47 - {
1.48 - SetEntityMoveType(target, MOVETYPE_NOCLIP);
1.49 - }
1.50 - else
1.51 - {
1.52 - SetEntityMoveType(target, MOVETYPE_WALK);
1.53 - }
1.54 -
1.55 - LogAction(client, target, "\"%L\" toggled noclip on \"%L\"", client, target);
1.56 -}
1.57 -
1.58 -public AdminMenu_NoClip(Handle:topmenu,
1.59 - TopMenuAction:action,
1.60 - TopMenuObject:object_id,
1.61 - param,
1.62 - String:buffer[],
1.63 - maxlength)
1.64 -{
1.65 - if (action == TopMenuAction_DisplayOption)
1.66 - {
1.67 - Format(buffer, maxlength, "%T", "NoClip player", param);
1.68 - }
1.69 - else if (action == TopMenuAction_SelectOption)
1.70 - {
1.71 - DisplayNoClipMenu(param);
1.72 - }
1.73 -}
1.74 -
1.75 -DisplayNoClipMenu(client)
1.76 -{
1.77 - new Handle:menu = CreateMenu(MenuHandler_NoClip);
1.78 -
1.79 - decl String:title[100];
1.80 - Format(title, sizeof(title), "%T:", "NoClip player", client);
1.81 - SetMenuTitle(menu, title);
1.82 - SetMenuExitBackButton(menu, true);
1.83 -
1.84 - AddTargetsToMenu(menu, client, true, true);
1.85 -
1.86 - DisplayMenu(menu, client, MENU_TIME_FOREVER);
1.87 -}
1.88 -
1.89 -public MenuHandler_NoClip(Handle:menu, MenuAction:action, param1, param2)
1.90 -{
1.91 - if (action == MenuAction_End)
1.92 - {
1.93 - CloseHandle(menu);
1.94 - }
1.95 - else if (action == MenuAction_Cancel)
1.96 - {
1.97 - if (param2 == MenuCancel_ExitBack && hTopMenu != INVALID_HANDLE)
1.98 - {
1.99 - DisplayTopMenu(hTopMenu, param1, TopMenuPosition_LastCategory);
1.100 - }
1.101 - }
1.102 - else if (action == MenuAction_Select)
1.103 - {
1.104 - decl String:info[32];
1.105 - new userid, target;
1.106 -
1.107 - GetMenuItem(menu, param2, info, sizeof(info));
1.108 - userid = StringToInt(info);
1.109 -
1.110 - if ((target = GetClientOfUserId(userid)) == 0)
1.111 - {
1.112 - PrintToChat(param1, "[SM] %t", "Player no longer available");
1.113 - }
1.114 - else if (!CanUserTarget(param1, target))
1.115 - {
1.116 - PrintToChat(param1, "[SM] %t", "Unable to target");
1.117 - }
1.118 - else
1.119 - {
1.120 - new String:name[32];
1.121 - GetClientName(target, name, sizeof(name));
1.122 -
1.123 - PerformNoClip(param1, target);
1.124 - ShowActivity2(param1, "[SM] ", "%t", "Toggled noclip on target", "_s", name);
1.125 - }
1.126 -
1.127 - /* Re-draw the menu if they're still valid */
1.128 - if (IsClientInGame(param1) && !IsClientInKickQueue(param1))
1.129 - {
1.130 - DisplayNoClipMenu(param1);
1.131 - }
1.132 - }
1.133 -}
1.134 -
1.135 -public Action:Command_NoClip(client, args)
1.136 -{
1.137 - if (args < 1)
1.138 - {
1.139 - ReplyToCommand(client, "[SM] Usage: sm_noclip <#userid|name>");
1.140 - return Plugin_Handled;
1.141 - }
1.142 -
1.143 - decl String:arg[65];
1.144 - GetCmdArg(1, arg, sizeof(arg));
1.145 -
1.146 - decl String:target_name[MAX_TARGET_LENGTH];
1.147 - decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;
1.148 -
1.149 - if ((target_count = ProcessTargetString(
1.150 - arg,
1.151 - client,
1.152 - target_list,
1.153 - MAXPLAYERS,
1.154 - COMMAND_FILTER_ALIVE,
1.155 - target_name,
1.156 - sizeof(target_name),
1.157 - tn_is_ml)) <= 0)
1.158 - {
1.159 - ReplyToTargetError(client, target_count);
1.160 - return Plugin_Handled;
1.161 - }
1.162 -
1.163 - for (new i = 0; i < target_count; i++)
1.164 - {
1.165 - PerformNoClip(client, target_list[i]);
1.166 - }
1.167 -
1.168 - if (tn_is_ml)
1.169 - {
1.170 - ShowActivity2(client, "[SM] ", "%t", "Toggled noclip on target", target_name);
1.171 - }
1.172 - else
1.173 - {
1.174 - ShowActivity2(client, "[SM] ", "%t", "Toggled noclip on target", "_s", target_name);
1.175 - }
1.176 -
1.177 - return Plugin_Handled;
1.178 -}