1.1 --- a/plugins/include/commandfilters.inc Fri Jul 11 06:51:21 2008 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,134 +0,0 @@
1.4 -/**
1.5 - * vim: set ts=4 :
1.6 - * =============================================================================
1.7 - * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
1.8 - * =============================================================================
1.9 - *
1.10 - * This file is part of the SourceMod/SourcePawn SDK.
1.11 - *
1.12 - * This program is free software; you can redistribute it and/or modify it under
1.13 - * the terms of the GNU General Public License, version 3.0, as published by the
1.14 - * Free Software Foundation.
1.15 - *
1.16 - * This program is distributed in the hope that it will be useful, but WITHOUT
1.17 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.18 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1.19 - * details.
1.20 - *
1.21 - * You should have received a copy of the GNU General Public License along with
1.22 - * this program. If not, see <http://www.gnu.org/licenses/>.
1.23 - *
1.24 - * As a special exception, AlliedModders LLC gives you permission to link the
1.25 - * code of this program (as well as its derivative works) to "Half-Life 2," the
1.26 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
1.27 - * by the Valve Corporation. You must obey the GNU General Public License in
1.28 - * all respects for all other code used. Additionally, AlliedModders LLC grants
1.29 - * this exception to all derivative works. AlliedModders LLC defines further
1.30 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
1.31 - * or <http://www.sourcemod.net/license.php>.
1.32 - *
1.33 - * Version: $Id$
1.34 - */
1.35 -
1.36 -#if defined _commandfilters_included
1.37 - #endinput
1.38 -#endif
1.39 -#define _commandfilters_included
1.40 -
1.41 -#define MAX_TARGET_LENGTH 64
1.42 -
1.43 -#define COMMAND_FILTER_ALIVE (1<<0) /**< Only allow alive players */
1.44 -#define COMMAND_FILTER_DEAD (1<<1) /**< Only filter dead players */
1.45 -#define COMMAND_FILTER_CONNECTED (1<<2) /**< Allow players not fully in-game */
1.46 -#define COMMAND_FILTER_NO_IMMUNITY (1<<3) /**< Ignore immunity rules */
1.47 -#define COMMAND_FILTER_NO_MULTI (1<<4) /**< Do not allow multiple target patterns */
1.48 -#define COMMAND_FILTER_NO_BOTS (1<<5) /**< Do not allow bots to be targetted */
1.49 -
1.50 -#define COMMAND_TARGET_NONE 0 /**< No target was found */
1.51 -#define COMMAND_TARGET_NOT_ALIVE -1 /**< Single client is not alive */
1.52 -#define COMMAND_TARGET_NOT_DEAD -2 /**< Single client is not dead */
1.53 -#define COMMAND_TARGET_NOT_IN_GAME -3 /**< Single client is not in game */
1.54 -#define COMMAND_TARGET_IMMUNE -4 /**< Single client is immune */
1.55 -#define COMMAND_TARGET_EMPTY_FILTER -5 /**< A multi-filter (such as @all) had no targets */
1.56 -#define COMMAND_TARGET_NOT_HUMAN -6 /**< Target was not human */
1.57 -#define COMMAND_TARGET_AMBIGUOUS -7 /**< Partial name had too many targets */
1.58 -
1.59 -/**
1.60 - * Processes a generic command target string, and resolves it to a list
1.61 - * of clients or one client, based on filtering rules and a pattern.
1.62 - *
1.63 - * Note that you should use LoadTranslations("common.phrases") in OnPluginStart(),
1.64 - * as that file is guaranteed to contain all of the translatable phrases that
1.65 - * ProcessTargetString() will return.
1.66 - *
1.67 - * @param pattern Pattern to find clients against.
1.68 - * @param admin Admin performing the action, or 0 if the server.
1.69 - * @param targets Array to hold targets.
1.70 - * @param max_targets Maximum size of the targets array.
1.71 - * @param filter_flags Filter flags.
1.72 - * @param target_name Buffer to store the target name.
1.73 - * @param tn_maxlength Maximum length of the target name buffer.
1.74 - * @param tn_is_ml OUTPUT: Will be true if the target name buffer is an ML phrase,
1.75 - * false if it is a normal string.
1.76 - * @return If a multi-target pattern was used, the number of clients found
1.77 - * is returned. If a single-target pattern was used, 1 is returned
1.78 - * if one valid client is found. Otherwise, a COMMAND_TARGET reason
1.79 - * for failure is returned.
1.80 - */
1.81 -native ProcessTargetString(const String:pattern[],
1.82 - admin,
1.83 - targets[],
1.84 - max_targets,
1.85 - filter_flags,
1.86 - String:target_name[],
1.87 - tn_maxlength,
1.88 - &bool:tn_is_ml);
1.89 -
1.90 -/**
1.91 - * Replies to a client with a given message describing a targetting
1.92 - * failure reason.
1.93 - *
1.94 - * Note: The translation phrases are found in common.phrases.txt.
1.95 - *
1.96 - * @param client Client index, or 0 for server.
1.97 - * @param reason COMMAND_TARGET reason.
1.98 - * @noreturn
1.99 - */
1.100 -stock ReplyToTargetError(client, reason)
1.101 -{
1.102 - switch (reason)
1.103 - {
1.104 - case COMMAND_TARGET_NONE:
1.105 - {
1.106 - ReplyToCommand(client, "[SM] %t", "No matching client");
1.107 - }
1.108 - case COMMAND_TARGET_NOT_ALIVE:
1.109 - {
1.110 - ReplyToCommand(client, "[SM] %t", "Target must be alive");
1.111 - }
1.112 - case COMMAND_TARGET_NOT_DEAD:
1.113 - {
1.114 - ReplyToCommand(client, "[SM] %t", "Target must be dead");
1.115 - }
1.116 - case COMMAND_TARGET_NOT_IN_GAME:
1.117 - {
1.118 - ReplyToCommand(client, "[SM] %t", "Target is not in game");
1.119 - }
1.120 - case COMMAND_TARGET_IMMUNE:
1.121 - {
1.122 - ReplyToCommand(client, "[SM] %t", "Unable to target");
1.123 - }
1.124 - case COMMAND_TARGET_EMPTY_FILTER:
1.125 - {
1.126 - ReplyToCommand(client, "[SM] %t", "No matching clients");
1.127 - }
1.128 - case COMMAND_TARGET_NOT_HUMAN:
1.129 - {
1.130 - ReplyToCommand(client, "[SM] %t", "Cannot target bot");
1.131 - }
1.132 - case COMMAND_TARGET_AMBIGUOUS:
1.133 - {
1.134 - ReplyToCommand(client, "[SM] %t", "More than one client matched");
1.135 - }
1.136 - }
1.137 -}