plugins/include/sdktools_functions.inc
author David Anderson <dvander@alliedmods.net>
Sun Oct 21 20:06:30 2007 +0000 (2007-10-21)
changeset 1621 ac5d4c68a99a
parent 1615 acf9a0befda7
child 1720 6a9ff57fb9f9
permissions -rw-r--r--
- 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
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     5  * =============================================================================
     6  *
     7  * This file is part of the SourceMod/SourcePawn SDK.
     8  *
     9  * This program is free software; you can redistribute it and/or modify it under
    10  * the terms of the GNU General Public License, version 3.0, as published by the
    11  * Free Software Foundation.
    12  * 
    13  * This program is distributed in the hope that it will be useful, but WITHOUT
    14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    15  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    16  * details.
    17  *
    18  * You should have received a copy of the GNU General Public License along with
    19  * this program.  If not, see <http://www.gnu.org/licenses/>.
    20  *
    21  * As a special exception, AlliedModders LLC gives you permission to link the
    22  * code of this program (as well as its derivative works) to "Half-Life 2," the
    23  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    24  * by the Valve Corporation.  You must obey the GNU General Public License in
    25  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    26  * this exception to all derivative works.  AlliedModders LLC defines further
    27  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    28  * or <http://www.sourcemod.net/license.php>.
    29  *
    30  * Version: $Id$
    31  */
    32 
    33 #if defined _sdktools_functions_included
    34   #endinput
    35 #endif
    36 #define _sdktools_functions_included
    37 
    38 /**
    39  * Removes a player's item.
    40  *
    41  * @param client		Client index.
    42  * @param item			CBaseCombatWeapon entity index.
    43  * @return				True on success, false otherwise.
    44  * @error				Invalid client or entity, lack of mod support, or client not in 
    45  *						game.
    46  */
    47 native bool:RemovePlayerItem(client, item);
    48 
    49 /**
    50  * Gives a named item to a player.
    51  *
    52  * @param client		Client index.
    53  * @param item			Item classname (such as weapon_ak47).
    54  * @param iSubType		Unknown.
    55  * @return				Entity index on success, or -1 on failure.
    56  * @error				Invalid client or client not in game, or lack of mod support.
    57  */
    58 native GivePlayerItem(client, const String:item[], iSubType=0);
    59 
    60 /**
    61  * Returns the weapon in a player's slot.  
    62  *
    63  * @param client		Client index.
    64  * @param slot			Slot index (mod specific).
    65  * @return				Entity index on success, -1 if no weapon existed.
    66  * @error				Invalid client or client not in game, or lack of mod support.
    67  */
    68 native GetPlayerWeaponSlot(client, slot);
    69 
    70 /**
    71  * Ignites an entity on fire.
    72  *
    73  * @param entity		Entity index.
    74  * @param time			Number of seconds to set on fire.
    75  * @param npc			True to only affect NPCs.
    76  * @param size			Unknown.
    77  * @param level			Unknown.
    78  * @noreturn
    79  * @error				Invalid entity or client not in game, or lack of mod support.
    80  */
    81 native IgniteEntity(entity, Float:time, bool:npc=false, Float:size=0.0, bool:level=false);
    82 
    83 /**
    84  * Extinguishes a player that is on fire.
    85  *
    86  * @param entity		Entity index.
    87  * @noreturn
    88  * @error				Invalid entity or client not in game, or lack of mod support.
    89  */
    90 native ExtinguishEntity(client);
    91 
    92 /**
    93  * Teleports an entity.
    94  *
    95  * @param entity		Client index.
    96  * @param origin		New origin, or NULL_VECTOR for no change.
    97  * @param angles		New angles, or NULL_VECTOR for no change.
    98  * @param velocity		New velocity, or NULL_VECTOR for no change.
    99  * @noreturn
   100  * @error				Invalid entity or client not in game, or lack of mod support.
   101  */
   102 native TeleportEntity(entity, const Float:origin[3], const Float:angles[3], const Float:velocity[3]);
   103 
   104 /**
   105  * Forces a player to commit suicide.
   106  *
   107  * @param client		Client index.
   108  * @noreturn
   109  * @error				Invalid client or client not in game, or lack of mod support.
   110  */
   111 native ForcePlayerSuicide(client);
   112 
   113 /**
   114  * Slaps a player in a random direction.
   115  *
   116  * @param client		Client index.
   117  * @param health		Health to subtract.
   118  * @param sound			False to disable the sound effects.
   119  * @noreturn
   120  * @error				Invalid client or client not in game, or lack of mod support.
   121  */
   122 native SlapPlayer(client, health=5, bool:sound=true);
   123 
   124 /**
   125  * Searches for an entity by classname.
   126  *
   127  * @param startEnt		The entity index to begin searching from.
   128  *						Use -1 to start from the first entity.
   129  * @param classname		Classname of the entity to find.
   130  * @return				Entity index >= 0 if found, -1 otherwise.
   131  * @error				Lack of mod support.
   132  */
   133 native FindEntityByClassname(startEnt, const String:classname[]);
   134 
   135 /**
   136  * Returns the client's eye angles.
   137  *
   138  * @param client		Player's index.
   139  * @param ang			Destination vector to store the client's eye angles.
   140  * @return				True on success, false on failure.
   141  * @error				Invalid client index, client not in game, or no mod support.
   142  */
   143 native bool:GetClientEyeAngles(client, Float:ang[3]);
   144 
   145 /**
   146  * Creates an entity by string name, but does not spawn it (see DispatchSpawn).
   147  * If ForceEdictIndex is not -1, then it will use the edict by that index. If the index is 
   148  *  invalid or there is already an edict using that index, it will error out.
   149  *
   150  * @param classname			Entity classname.
   151  * @param ForceEdictIndex	Edict index used by the created entity.
   152  * @return					Entity index on success, or -1 on failure.
   153  * @error					Invalid edict index, or no mod support.
   154  */
   155 native CreateEntityByName(const String:classname[], ForceEdictIndex=-1);
   156 
   157 /**
   158  * Spawns an entity into the game.
   159  *
   160  * @param entity		Entity index of the created entity.
   161  * @return				True on success, false otherwise.
   162  * @error				Invalid entity index, or no mod support.
   163  */
   164 native bool:DispatchSpawn(entity);
   165 
   166 /**
   167  * Dispatches a KeyValue into given entity using a string value.
   168  *
   169  * @param entity		Destination entity index.
   170  * @param keyName		Name of the key.
   171  * @param value			String value.
   172  * @return				True on success, false otherwise.
   173  * @error				Invalid entity index, or no mod support.
   174  */
   175 native bool:DispatchKeyValue(entity, const String:keyName[], const String:value[]);
   176 
   177 /**
   178  * Dispatches a KeyValue into given entity using a floating point value.
   179  *
   180  * @param entity		Destination entity index.
   181  * @param keyName		Name of the key.
   182  * @param value			Floating point value.
   183  * @return				True on success, false otherwise.
   184  * @error				Invalid entity index, or no mod support.
   185  */
   186 native bool:DispatchKeyValueFloat(entity, const String:keyName[], Float:value);
   187 
   188 /**
   189  * Dispatches a KeyValue into given entity using a vector value.
   190  *
   191  * @param entity		Destination entity index.
   192  * @param keyName		Name of the key.
   193  * @param vec			Vector value.
   194  * @return				True on success, false otherwise.
   195  * @error				Invalid entity index, or no mod support.
   196  */
   197 native bool:DispatchKeyValueVector(entity, const String:keyName[], const Float:vector[3]);
   198 
   199 /**
   200  * Returns the entity a client is aiming at.
   201  *
   202  * @param client		Client performing the aiming.
   203  * @param only_clients	True to exclude all entities but clients.
   204  * @return				Entity index being aimed at.
   205  *						-1 if no entity is being aimed at.
   206  * 						-2 if the function is not supported.
   207  * @error				Invalid client index or client not in game.
   208  */
   209 native GetClientAimTarget(client, bool:only_clients=true);
   210 
   211 /**
   212  * Returns the total number of teams in a game.
   213  *
   214  * @return				Total number of teams.
   215  */
   216 native GetTeamCount();
   217 
   218 /**
   219  * Retrieves the team name based on a team index.
   220  *
   221  * @param index				Team index.
   222  * @param name				Buffer to store string in.
   223  * @param maxlength			Maximum length of string buffer.
   224  * @noreturn
   225  * @error				Invalid team index.
   226  */
   227 native GetTeamName(index, String:name[], maxlength);
   228 
   229 /**
   230  * Returns the score of a team based on a team index.
   231  *
   232  * @param index				Team index.
   233  * @return				Score.
   234  * @error				Invalid team index.
   235  */
   236 native GetTeamScore(index);
   237 
   238 /**
   239  * Sets the score of a team based on a team index.
   240  *
   241  * @param index				Team index.
   242  * @param value				New score value.
   243  * @return				Score.
   244  * @error				Invalid team index.
   245  */
   246 native SetTeamScore(index, value);
   247 
   248 /**
   249  * Retrieves the number of players in a certain team.
   250  *
   251  * @param index				Team index.
   252  * @return				Number of players in the team.
   253  * @error				Invalid team index.
   254  */
   255 native GetTeamClientCount(index);
   256 
   257 /**
   258  * @deprecated
   259  */
   260 #pragma deprecated Use IgniteEntity() instead
   261 stock IgnitePlayer(client, Float:time, bool:npc=false, Float:size=0.0, bool:level=false)
   262 {
   263 	return IgniteEntity(client, time, npc, size, level);
   264 }
   265 
   266 /**
   267  * @deprecated
   268  */
   269 #pragma deprecated Use ExtinguishEntity() instead
   270 stock ExtinguishClient(client)
   271 {
   272 	return ExtinguishEntity(client);
   273 }
   274 
   275 /**
   276  * @deprecated
   277  */
   278 #pragma deprecated Use TeleportEntity() instead
   279 stock TeleportPlayer(client, const Float:origin[3], const Float:angles[3], const Float:velocity[3])
   280 {
   281 	return TeleportEntity(client, origin, angles, velocity);
   282 }