plugins/include/sdktools_functions.inc
author Erik Minekus <erik@minekus.com>
Thu Aug 01 09:26:34 2013 -0400 (2013-08-01)
changeset 3967 ceafb87d38a7
parent 3280 7aea1316eff7
child 4004 91974ce16453
permissions -rw-r--r--
Numerous code documentation fixups (bug 5720, r=psychonic).
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod (C)2004-2008 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 an entity 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(entity);
    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 after which 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 (ignored on Orangebox and above).
   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:vec[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  * Note: This native should not be called before OnMapStart.
   214  *
   215  * @return				Total number of teams.
   216  */
   217 native GetTeamCount();
   218 
   219 /**
   220  * Retrieves the team name based on a team index.
   221  * Note: This native should not be called before OnMapStart.
   222  *
   223  * @param index				Team index.
   224  * @param name				Buffer to store string in.
   225  * @param maxlength			Maximum length of string buffer.
   226  * @noreturn
   227  * @error				Invalid team index.
   228  */
   229 native GetTeamName(index, String:name[], maxlength);
   230 
   231 /**
   232  * Returns the score of a team based on a team index.
   233  * Note: This native should not be called before OnMapStart.
   234  *
   235  * @param index				Team index.
   236  * @return				Score.
   237  * @error				Invalid team index.
   238  */
   239 native GetTeamScore(index);
   240 
   241 /**
   242  * Sets the score of a team based on a team index.
   243  * Note: This native should not be called before OnMapStart.
   244  *
   245  * @param index				Team index.
   246  * @param value				New score value.
   247  * @return				Score.
   248  * @error				Invalid team index.
   249  */
   250 native SetTeamScore(index, value);
   251 
   252 /**
   253  * Retrieves the number of players in a certain team.
   254  * Note: This native should not be called before OnMapStart.
   255  *
   256  * @param index				Team index.
   257  * @return				Number of players in the team.
   258  * @error				Invalid team index.
   259  */
   260 native GetTeamClientCount(index);
   261 
   262 /**
   263  * Sets the model to a given entity.
   264  *
   265  * @param entity			Entity index.
   266  * @param model				Model name.
   267  * @noreturn
   268  * @error				Invalid entity index, or no mod support.
   269  */
   270 native SetEntityModel(entity, const String:model[]);
   271 
   272 /**
   273  * Retrieves the decal file name associated to a given client.
   274  *
   275  * @param client			Player's index.
   276  * @param hex				Buffer to store the logo filename.
   277  * @param maxlength			Maximum length of string buffer.
   278  * @return				True on success, otherwise false.
   279  * @error				Invalid client or client not in game.
   280  */
   281 native bool:GetPlayerDecalFile(client, String:hex[], maxlength);
   282 
   283 /**
   284  * Returns the average server network traffic in bytes/sec.
   285  *
   286  * @param in				Buffer to store the input traffic velocity.
   287  * @param out				Buffer to store the output traffic velocity.
   288  * @noreturn
   289  */
   290 native GetServerNetStats(&Float:in, &Float:out);
   291 
   292 /**
   293  * Equip's a player's weapon.
   294  *
   295  * @param client		Client index.
   296  * @param weapon			CBaseCombatWeapon entity index.
   297  * @noreturn
   298  * @error				Invalid client or entity, lack of mod support, or client not in 
   299  *						game.
   300  */
   301 native EquipPlayerWeapon(client, weapon);
   302 
   303 /**
   304  * Activates an entity (CBaseAnimating::Activate)
   305  *
   306  * @param entity		Entity index.
   307  * @noreturn
   308  * @error				Invalid entity or lack of mod support.
   309  */
   310 native ActivateEntity(entity);
   311 
   312 /**
   313  * Sets values to client info buffer keys and notifies the engine of the change.
   314  * The change does not get propogated to mods until the next frame.
   315  *
   316  * @param client		Player's index.
   317  * @param key			Key string.
   318  * @param value			Value string.
   319  * @noreturn
   320  * @error				Invalid client index, or client not connected.
   321  */
   322 native SetClientInfo(client, const String:key[], const String:value[]);