plugins/include/sdktools_tempents.inc
author David Anderson <dvander@alliedmods.net>
Sun Aug 11 11:30:27 2013 -0700 (2013-08-11)
changeset 3984 d94a0d3bc008
parent 2920 1d5645ab7ae0
permissions -rw-r--r--
Clean up INFO register structure (bug 5844 part 1, r=ds).
     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_tempents_included
    34  #endinput
    35 #endif
    36 #define _sdktools_tempents_included
    37 
    38 /**
    39  * Called when a temp entity is going to be sent.
    40  *
    41  * @param te_name	TE name.
    42  * @param Players	Array containing target player indexes.
    43  * @param numClients	Number of players in the array.
    44  * @param delay		Delay in seconds to send the TE.
    45  * @return		Plugin_Continue to allow the transmission of the TE, Plugin_Stop to block it.
    46  */
    47 functag public Action:TEHook(const String:te_name[], const Players[], numClients, Float:delay);
    48 
    49 /**
    50  * Hooks a temp entity.
    51  *
    52  * @param te_name	TE name to hook.
    53  * @param hook		Function to use as a hook.
    54  * @noreturn
    55  * @error		Temp Entity name not available or invalid function hook.
    56  */
    57 native AddTempEntHook(const String:te_name[], TEHook:hook);
    58 
    59 /**
    60  * Removes a temp entity hook.
    61  *
    62  * @param te_name	TE name to unhook.
    63  * @param hook		Function used for the hook.
    64  * @noreturn
    65  * @error		Temp Entity name not available or invalid function hook.
    66  */
    67 native RemoveTempEntHook(const String:te_name[], TEHook:hook);
    68 
    69 /**
    70  * Starts a temp entity transmission.
    71  *
    72  * @param te_name	TE name.
    73  * @noreturn
    74  * @error		Temp Entity name not available.
    75  */
    76 native TE_Start(const String:te_name[]);
    77 
    78 /**
    79  * Checks if a certain TE property exists.
    80  *
    81  * @param prop		Property to use.
    82  * @return		True if the property exists, otherwise false.
    83  */
    84 native bool:TE_IsValidProp(const String:prop[]);
    85 
    86 /**
    87  * Sets an integer value in the current temp entity.
    88  *
    89  * @param prop		Property to use.
    90  * @param value		Integer value to set.
    91  * @noreturn
    92  * @error		Property not found.
    93  */
    94 native TE_WriteNum(const String:prop[], value);
    95 
    96 /**
    97  * Reads an integer value in the current temp entity.
    98  *
    99  * @param prop		Property to use.
   100  * @return		Property value.
   101  * @error		Property not found.
   102  */
   103 native TE_ReadNum(const String:prop[]);
   104 
   105 /**
   106  * Sets a floating point number in the current temp entity.
   107  *
   108  * @param prop		Property to use.
   109  * @param value		Floating point number to set.
   110  * @noreturn
   111  * @error		Property not found.
   112  */
   113 native TE_WriteFloat(const String:prop[], Float:value);
   114 
   115 /**
   116  * Reads a floating point number in the current temp entity.
   117  *
   118  * @param prop		Property to use.
   119  * @noreturn		Property value.
   120  * @error		Property not found.
   121  */
   122 native Float:TE_ReadFloat(const String:prop[]);
   123 
   124 /**
   125  * Sets a vector in the current temp entity.
   126  *
   127  * @param prop		Property to use.
   128  * @param vector	Vector to set.
   129  * @noreturn
   130  * @error		Property not found.
   131  */
   132 native TE_WriteVector(const String:prop[], const Float:vector[3]);
   133 
   134 /**
   135  * Reads a vector in the current temp entity.
   136  *
   137  * @param prop		Property to use.
   138  * @param vector	Vector to read.
   139  * @noreturn
   140  * @error		Property not found.
   141  */
   142 native TE_ReadVector(const String:prop[], Float:vector[3]);
   143 
   144 /**
   145  * Sets a QAngle in the current temp entity.
   146  *
   147  * @param prop		Property to use.
   148  * @param angles	Angles to set.
   149  * @return		True on success, otherwise false.
   150  * @error		Property not found.
   151  */
   152 native TE_WriteAngles(const String:prop[], const Float:angles[3]);
   153 
   154 /**
   155  * Sets an array of floats in the current temp entity.
   156  *
   157  * @param prop		Property to use.
   158  * @param array		Array of values to copy.
   159  * @param arraySize	Number of values to copy.
   160  * @return		True on success, otherwise false.
   161  * @error		Property not found.
   162  */
   163 native TE_WriteFloatArray(const String:prop[], const Float:array[], arraySize);
   164 
   165 /**
   166  * Sends the current temp entity to one or more clients.
   167  *
   168  * @param clients	Array containing player indexes to broadcast to.
   169  * @param numClients	Number of players in the array.
   170  * @param delay		Delay in seconds to send the TE.
   171  * @noreturn
   172  * @error		Invalid client index or client not in game.
   173  */
   174 native TE_Send(clients[], numClients, Float:delay=0.0);
   175 
   176 /**
   177  * Sets an encoded entity index in the current temp entity.
   178  * (This is usually used for m_nStartEntity and m_nEndEntity).
   179  *
   180  * @param prop		Property to use.
   181  * @param value		Value to set.
   182  * @noreturn
   183  * @error		Property not found.
   184  */
   185 stock TE_WriteEncodedEnt(const String:prop[], value)
   186 {
   187 	new encvalue = (value & 0x0FFF) | ((1 & 0xF)<<12);
   188 	return TE_WriteNum(prop, encvalue);
   189 }
   190 
   191 /**
   192  * Broadcasts the current temp entity to all clients.
   193  * @note See TE_Start().
   194  *
   195  * @param delay		Delay in seconds to send the TE.
   196  * @noreturn
   197  */
   198 stock TE_SendToAll(Float:delay=0.0)
   199 {
   200 	new total = 0;
   201 	new clients[MaxClients];
   202 	for (new i=1; i<=MaxClients; i++)
   203 	{
   204 		if (IsClientInGame(i))
   205 		{
   206 			clients[total++] = i;
   207 		}
   208 	}
   209 	return TE_Send(clients, total, delay);
   210 }
   211 
   212 /**
   213  * Sends the current TE to only a client.
   214  * @note See TE_Start().
   215  *
   216  * @param client	Client to send to.
   217  * @param delay		Delay in seconds to send the TE.
   218  * @noreturn
   219  * @error		Invalid client index or client not in game.
   220  */
   221 stock TE_SendToClient(client, Float:delay=0.0)
   222 {
   223 	new players[1];
   224 
   225 	players[0] = client;
   226 
   227 	return TE_Send(players, 1, delay);
   228 }