- added ShowActivity2() which has a more convenient display algorithm
- added commandfilters.inc and ProcessTargetString(), an extensible API for processing a command target and getting back formatted replies + player lists. This makes SearchForClients() look paltry, and base plugins will slowly be moved to support the new functionality - removed IsPlayerAlive() from SDKTools, added it to Core - fixed a small bug in re-entrant translations - core.games.txt is now automatically added to all plugins --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401627
This commit is contained in:
@@ -255,6 +255,17 @@ native bool:IsFakeClient(client);
|
||||
*/
|
||||
native bool:IsClientObserver(client);
|
||||
|
||||
/**
|
||||
* Returns if the client is alive or dead.
|
||||
*
|
||||
* Note: This function was originally in SDKTools and was moved to core.
|
||||
*
|
||||
* @param client Player's index.
|
||||
* @return True if the client is alive, false otherwise.
|
||||
* @error Invalid client index, client not in game, or no mod support.
|
||||
*/
|
||||
native bool:IsPlayerAlive(client);
|
||||
|
||||
/**
|
||||
* Retrieves values from client replicated keys.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
|
||||
* =============================================================================
|
||||
*
|
||||
* This file is part of the SourceMod/SourcePawn SDK.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||
* this exception to all derivative works. AlliedModders LLC defines further
|
||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||
* or <http://www.sourcemod.net/license.php>.
|
||||
*
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#if defined _commandfilters_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _commandfilters_included
|
||||
|
||||
#define MAX_TARGET_LENGTH 64
|
||||
|
||||
#define COMMAND_FILTER_ALIVE (1<<0) /* Only allow alive players */
|
||||
#define COMMAND_FILTER_DEAD (1<<1) /* Only filter dead players */
|
||||
#define COMMAND_FILTER_CONNECTED (1<<2) /* Allow players not fully in-game */
|
||||
#define COMMAND_FILTER_NO_IMMUNITY (1<<3) /* Ignore immunity rules */
|
||||
#define COMMAND_FILTER_NO_MULTI (1<<4) /* Do not allow multiple target patterns */
|
||||
#define COMMAND_FILTER_NO_BOTS (1<<5) /* Do not allow bots to be targetted */
|
||||
|
||||
#define COMMAND_TARGET_NONE 0 /* No target was found */
|
||||
#define COMMAND_TARGET_NOT_ALIVE -1 /* Single client is not alive */
|
||||
#define COMMAND_TARGET_NOT_DEAD -2 /* Single client is not dead */
|
||||
#define COMMAND_TARGET_NOT_IN_GAME -3 /* Single client is not in game */
|
||||
#define COMMAND_TARGET_IMMUNE -4 /* Single client is immune */
|
||||
#define COMMAND_TARGET_EMPTY_FILTER -5 /* A multi-filter (such as @all) had no targets */
|
||||
#define COMMAND_TARGET_NOT_HUMAN -6 /* Target was not human */
|
||||
#define COMMAND_TARGET_AMBIGUOUS -7 /* Partial name had too many targets */
|
||||
|
||||
/**
|
||||
* Processes a generic command target string, and resolves it to a list
|
||||
* of clients or one client, based on filtering rules and a pattern.
|
||||
*
|
||||
* @param pattern Pattern to find clients against.
|
||||
* @param admin Admin performing the action, or 0 if the server.
|
||||
* @param targets Array to hold targets.
|
||||
* @param max_targets Maximum size of the targets array.
|
||||
* @param filter_flags Filter flags.
|
||||
* @param target_name Buffer to store the target name.
|
||||
* @param tn_maxlength Maximum length of the target name buffer.
|
||||
* @param tn_is_ml Set to true if the target name buffer is an ML phrase,
|
||||
* false if it is a normal string.
|
||||
* @return If a multi-target pattern was used, the number of clients found
|
||||
* is returned. If a single-target pattern was used, 1 is returned
|
||||
* if one valid client is found. Otherwise, a CLIENT_TARGET reason
|
||||
* for failure is returned.
|
||||
*/
|
||||
native ProcessTargetString(const String:pattern[],
|
||||
admin,
|
||||
targets[],
|
||||
max_targets,
|
||||
filter_flags,
|
||||
String:target_name[],
|
||||
tn_maxlength,
|
||||
&bool:tn_is_ml);
|
||||
|
||||
/**
|
||||
* Replies to a client with a given message describing a targetting
|
||||
* failure reason.
|
||||
*
|
||||
* Note: The translation phrases are found in common.phrases.txt.
|
||||
*
|
||||
* @param client Client index, or 0 for server.
|
||||
* @param reason COMMAND_TARGET reason.
|
||||
* @noreturn
|
||||
*/
|
||||
stock ReplyToTargetError(client, reason)
|
||||
{
|
||||
switch (reason)
|
||||
{
|
||||
case COMMAND_TARGET_NONE:
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "No matching client");
|
||||
}
|
||||
case COMMAND_TARGET_NOT_ALIVE:
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Target must be alive");
|
||||
}
|
||||
case COMMAND_TARGET_NOT_DEAD:
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Target must be dead");
|
||||
}
|
||||
case COMMAND_TARGET_NOT_IN_GAME:
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Target is not in game");
|
||||
}
|
||||
case COMMAND_TARGET_IMMUNE:
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Unable to target");
|
||||
}
|
||||
case COMMAND_TARGET_EMPTY_FILTER:
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "No matching clients");
|
||||
}
|
||||
case COMMAND_TARGET_NOT_HUMAN:
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "Cannot target bot");
|
||||
}
|
||||
case COMMAND_TARGET_AMBIGUOUS:
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "More than one client matched");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -241,9 +241,10 @@ native bool:IsChatTrigger();
|
||||
|
||||
/**
|
||||
* Displays usage of an admin command to users depending on the
|
||||
* setting of the sm_show_activity cvar. Additionally, the client
|
||||
* who typed the command will receive the same text without any
|
||||
* client name prefix (as a confirmation).
|
||||
* setting of the sm_show_activity cvar.
|
||||
*
|
||||
* If the original client did not use a console command, they will
|
||||
* not see the public display in their chat.
|
||||
*
|
||||
* @param client Client index doing the action, or 0 for server.
|
||||
* @param format Formatting rules.
|
||||
@@ -266,6 +267,19 @@ native ShowActivity(client, const String:format[], any:...);
|
||||
*/
|
||||
native ShowActivityEx(client, const String:tag[], const String:format[], any:...);
|
||||
|
||||
/**
|
||||
* Same as ShowActivityEx(), except the text will always be mirrored to the
|
||||
* client's chat (and console, if the reply source specifies as such).
|
||||
*
|
||||
* @param client Client index doing the action, or 0 for server.
|
||||
* @param tag Tag to display with.
|
||||
* @param format Formatting rules.
|
||||
* @param ... Variable number of format parameters.
|
||||
* @noreturn
|
||||
* @error
|
||||
*/
|
||||
native ShowActivity2(client, const String:tag[], const String:format[], any:...);
|
||||
|
||||
/**
|
||||
* Called when a server-only command is invoked.
|
||||
*
|
||||
|
||||
@@ -142,15 +142,6 @@ native FindEntityByClassname(startEnt, const String:classname[]);
|
||||
*/
|
||||
native bool:GetClientEyeAngles(client, Float:ang[3]);
|
||||
|
||||
/**
|
||||
* Returns if the client is alive or dead.
|
||||
*
|
||||
* @param client Player's index.
|
||||
* @return True if the client is alive, false otherwise.
|
||||
* @error Invalid client index, client not in game, or no mod support.
|
||||
*/
|
||||
native bool:IsPlayerAlive(client);
|
||||
|
||||
/**
|
||||
* Creates an entity by string name, but does not spawn it (see DispatchSpawn).
|
||||
* If ForceEdictIndex is not -1, then it will use the edict by that index. If the index is
|
||||
|
||||
@@ -70,6 +70,7 @@ struct Plugin
|
||||
#include <halflife>
|
||||
#include <adt>
|
||||
#include <banning>
|
||||
#include <commandfilters>
|
||||
|
||||
/**
|
||||
* Declare this as a struct in your plugin to expose its information.
|
||||
|
||||
Reference in New Issue
Block a user