plugins/include/sdktools_functions.inc
branchrefac-jit
changeset 2168 c24a6fa957db
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/plugins/include/sdktools_functions.inc	Sun Jul 06 04:49:55 2008 +0000
     1.3 @@ -0,0 +1,322 @@
     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 _sdktools_functions_included
    1.37 +  #endinput
    1.38 +#endif
    1.39 +#define _sdktools_functions_included
    1.40 +
    1.41 +/**
    1.42 + * Removes a player's item.
    1.43 + *
    1.44 + * @param client		Client index.
    1.45 + * @param item			CBaseCombatWeapon entity index.
    1.46 + * @return				True on success, false otherwise.
    1.47 + * @error				Invalid client or entity, lack of mod support, or client not in 
    1.48 + *						game.
    1.49 + */
    1.50 +native bool:RemovePlayerItem(client, item);
    1.51 +
    1.52 +/**
    1.53 + * Gives a named item to a player.
    1.54 + *
    1.55 + * @param client		Client index.
    1.56 + * @param item			Item classname (such as weapon_ak47).
    1.57 + * @param iSubType		Unknown.
    1.58 + * @return				Entity index on success, or -1 on failure.
    1.59 + * @error				Invalid client or client not in game, or lack of mod support.
    1.60 + */
    1.61 +native GivePlayerItem(client, const String:item[], iSubType=0);
    1.62 +
    1.63 +/**
    1.64 + * Returns the weapon in a player's slot.  
    1.65 + *
    1.66 + * @param client		Client index.
    1.67 + * @param slot			Slot index (mod specific).
    1.68 + * @return				Entity index on success, -1 if no weapon existed.
    1.69 + * @error				Invalid client or client not in game, or lack of mod support.
    1.70 + */
    1.71 +native GetPlayerWeaponSlot(client, slot);
    1.72 +
    1.73 +/**
    1.74 + * Ignites an entity on fire.
    1.75 + *
    1.76 + * @param entity		Entity index.
    1.77 + * @param time			Number of seconds to set on fire.
    1.78 + * @param npc			True to only affect NPCs.
    1.79 + * @param size			Unknown.
    1.80 + * @param level			Unknown.
    1.81 + * @noreturn
    1.82 + * @error				Invalid entity or client not in game, or lack of mod support.
    1.83 + */
    1.84 +native IgniteEntity(entity, Float:time, bool:npc=false, Float:size=0.0, bool:level=false);
    1.85 +
    1.86 +/**
    1.87 + * Extinguishes a player that is on fire.
    1.88 + *
    1.89 + * @param entity		Entity index.
    1.90 + * @noreturn
    1.91 + * @error				Invalid entity or client not in game, or lack of mod support.
    1.92 + */
    1.93 +native ExtinguishEntity(client);
    1.94 +
    1.95 +/**
    1.96 + * Teleports an entity.
    1.97 + *
    1.98 + * @param entity		Client index.
    1.99 + * @param origin		New origin, or NULL_VECTOR for no change.
   1.100 + * @param angles		New angles, or NULL_VECTOR for no change.
   1.101 + * @param velocity		New velocity, or NULL_VECTOR for no change.
   1.102 + * @noreturn
   1.103 + * @error				Invalid entity or client not in game, or lack of mod support.
   1.104 + */
   1.105 +native TeleportEntity(entity, const Float:origin[3], const Float:angles[3], const Float:velocity[3]);
   1.106 +
   1.107 +/**
   1.108 + * Forces a player to commit suicide.
   1.109 + *
   1.110 + * @param client		Client index.
   1.111 + * @noreturn
   1.112 + * @error				Invalid client or client not in game, or lack of mod support.
   1.113 + */
   1.114 +native ForcePlayerSuicide(client);
   1.115 +
   1.116 +/**
   1.117 + * Slaps a player in a random direction.
   1.118 + *
   1.119 + * @param client		Client index.
   1.120 + * @param health		Health to subtract.
   1.121 + * @param sound			False to disable the sound effects.
   1.122 + * @noreturn
   1.123 + * @error				Invalid client or client not in game, or lack of mod support.
   1.124 + */
   1.125 +native SlapPlayer(client, health=5, bool:sound=true);
   1.126 +
   1.127 +/**
   1.128 + * Searches for an entity by classname.
   1.129 + *
   1.130 + * @param startEnt		The entity index after which to begin searching from.
   1.131 + *						Use -1 to start from the first entity.
   1.132 + * @param classname		Classname of the entity to find.
   1.133 + * @return				Entity index >= 0 if found, -1 otherwise.
   1.134 + * @error				Lack of mod support.
   1.135 + */
   1.136 +native FindEntityByClassname(startEnt, const String:classname[]);
   1.137 +
   1.138 +/**
   1.139 + * Returns the client's eye angles.
   1.140 + *
   1.141 + * @param client		Player's index.
   1.142 + * @param ang			Destination vector to store the client's eye angles.
   1.143 + * @return				True on success, false on failure.
   1.144 + * @error				Invalid client index, client not in game, or no mod support.
   1.145 + */
   1.146 +native bool:GetClientEyeAngles(client, Float:ang[3]);
   1.147 +
   1.148 +/**
   1.149 + * Creates an entity by string name, but does not spawn it (see DispatchSpawn).
   1.150 + * If ForceEdictIndex is not -1, then it will use the edict by that index. If the index is 
   1.151 + *  invalid or there is already an edict using that index, it will error out.
   1.152 + *
   1.153 + * @param classname			Entity classname.
   1.154 + * @param ForceEdictIndex	Edict index used by the created entity.
   1.155 + * @return					Entity index on success, or -1 on failure.
   1.156 + * @error					Invalid edict index, or no mod support.
   1.157 + */
   1.158 +native CreateEntityByName(const String:classname[], ForceEdictIndex=-1);
   1.159 +
   1.160 +/**
   1.161 + * Spawns an entity into the game.
   1.162 + *
   1.163 + * @param entity		Entity index of the created entity.
   1.164 + * @return				True on success, false otherwise.
   1.165 + * @error				Invalid entity index, or no mod support.
   1.166 + */
   1.167 +native bool:DispatchSpawn(entity);
   1.168 +
   1.169 +/**
   1.170 + * Dispatches a KeyValue into given entity using a string value.
   1.171 + *
   1.172 + * @param entity		Destination entity index.
   1.173 + * @param keyName		Name of the key.
   1.174 + * @param value			String value.
   1.175 + * @return				True on success, false otherwise.
   1.176 + * @error				Invalid entity index, or no mod support.
   1.177 + */
   1.178 +native bool:DispatchKeyValue(entity, const String:keyName[], const String:value[]);
   1.179 +
   1.180 +/**
   1.181 + * Dispatches a KeyValue into given entity using a floating point value.
   1.182 + *
   1.183 + * @param entity		Destination entity index.
   1.184 + * @param keyName		Name of the key.
   1.185 + * @param value			Floating point value.
   1.186 + * @return				True on success, false otherwise.
   1.187 + * @error				Invalid entity index, or no mod support.
   1.188 + */
   1.189 +native bool:DispatchKeyValueFloat(entity, const String:keyName[], Float:value);
   1.190 +
   1.191 +/**
   1.192 + * Dispatches a KeyValue into given entity using a vector value.
   1.193 + *
   1.194 + * @param entity		Destination entity index.
   1.195 + * @param keyName		Name of the key.
   1.196 + * @param vec			Vector value.
   1.197 + * @return				True on success, false otherwise.
   1.198 + * @error				Invalid entity index, or no mod support.
   1.199 + */
   1.200 +native bool:DispatchKeyValueVector(entity, const String:keyName[], const Float:vector[3]);
   1.201 +
   1.202 +/**
   1.203 + * Returns the entity a client is aiming at.
   1.204 + *
   1.205 + * @param client		Client performing the aiming.
   1.206 + * @param only_clients	True to exclude all entities but clients.
   1.207 + * @return				Entity index being aimed at.
   1.208 + *						-1 if no entity is being aimed at.
   1.209 + * 						-2 if the function is not supported.
   1.210 + * @error				Invalid client index or client not in game.
   1.211 + */
   1.212 +native GetClientAimTarget(client, bool:only_clients=true);
   1.213 +
   1.214 +/**
   1.215 + * Returns the total number of teams in a game.
   1.216 + * Note: This native should not be called before OnMapStart.
   1.217 + *
   1.218 + * @return				Total number of teams.
   1.219 + */
   1.220 +native GetTeamCount();
   1.221 +
   1.222 +/**
   1.223 + * Retrieves the team name based on a team index.
   1.224 + * Note: This native should not be called before OnMapStart.
   1.225 + *
   1.226 + * @param index				Team index.
   1.227 + * @param name				Buffer to store string in.
   1.228 + * @param maxlength			Maximum length of string buffer.
   1.229 + * @noreturn
   1.230 + * @error				Invalid team index.
   1.231 + */
   1.232 +native GetTeamName(index, String:name[], maxlength);
   1.233 +
   1.234 +/**
   1.235 + * Returns the score of a team based on a team index.
   1.236 + * Note: This native should not be called before OnMapStart.
   1.237 + *
   1.238 + * @param index				Team index.
   1.239 + * @return				Score.
   1.240 + * @error				Invalid team index.
   1.241 + */
   1.242 +native GetTeamScore(index);
   1.243 +
   1.244 +/**
   1.245 + * Sets the score of a team based on a team index.
   1.246 + * Note: This native should not be called before OnMapStart.
   1.247 + *
   1.248 + * @param index				Team index.
   1.249 + * @param value				New score value.
   1.250 + * @return				Score.
   1.251 + * @error				Invalid team index.
   1.252 + */
   1.253 +native SetTeamScore(index, value);
   1.254 +
   1.255 +/**
   1.256 + * Retrieves the number of players in a certain team.
   1.257 + * Note: This native should not be called before OnMapStart.
   1.258 + *
   1.259 + * @param index				Team index.
   1.260 + * @return				Number of players in the team.
   1.261 + * @error				Invalid team index.
   1.262 + */
   1.263 +native GetTeamClientCount(index);
   1.264 +
   1.265 +/**
   1.266 + * Sets the model to a given entity.
   1.267 + *
   1.268 + * @param entity			Entity index.
   1.269 + * @param model				Model name.
   1.270 + * @noreturn
   1.271 + * @error				Invalid entity index, or no mod support.
   1.272 + */
   1.273 +native SetEntityModel(entity, const String:model[]);
   1.274 +
   1.275 +/**
   1.276 + * Retrieves the decal file name associated to a given client.
   1.277 + *
   1.278 + * @param client			Player's index.
   1.279 + * @param hex				Buffer to store the logo filename.
   1.280 + * @param maxlength			Maximum length of string buffer.
   1.281 + * @return				True on success, otherwise false.
   1.282 + * @error				Invalid client or client not in game.
   1.283 + */
   1.284 +native bool:GetPlayerDecalFile(client, String:hex[], maxlength);
   1.285 +
   1.286 +/**
   1.287 + * Returns the average server network traffic in bytes/sec.
   1.288 + *
   1.289 + * @param in				Buffer to store the input traffic velocity.
   1.290 + * @param out				Buffer to store the output traffic velocity.
   1.291 + * @noreturn
   1.292 + */
   1.293 +native GetServerNetStats(&Float:in, &Float:out);
   1.294 +
   1.295 +/**
   1.296 + * Equip's a player's weapon.
   1.297 + *
   1.298 + * @param client		Client index.
   1.299 + * @param item			CBaseCombatWeapon entity index.
   1.300 + * @noreturn
   1.301 + * @error				Invalid client or entity, lack of mod support, or client not in 
   1.302 + *						game.
   1.303 + */
   1.304 +native EquipPlayerWeapon(client, weapon);
   1.305 +
   1.306 +/**
   1.307 + * Activates an entity (CBaseAnimating::Activate)
   1.308 + *
   1.309 + * @param entity		Entity index.
   1.310 + * @noreturn
   1.311 + * @error				Invalid entity or lack of mod support.
   1.312 + */
   1.313 +native ActivateEntity(entity);
   1.314 +
   1.315 +/**
   1.316 + * Sets values to client info buffer keys and notifies the engine of the change.
   1.317 + * The change does not get propogated to mods until the next frame.
   1.318 + *
   1.319 + * @param client		Player's index.
   1.320 + * @param key			Key string.
   1.321 + * @param value			Value string.
   1.322 + * @noreturn
   1.323 + * @error				Invalid client index, or client not connected.
   1.324 + */
   1.325 +native SetClientInfo(client, const String:key[], const String:value[]);