plugins/include/sdktools_tempents.inc
author Borja Ferrer <faluco@alliedmods.net>
Fri Aug 03 01:58:34 2007 +0000 (2007-08-03)
changeset 1256 76416aff76c3
parent 1255 e3db1a9eb578
child 1330 ab94316bb52b
permissions -rw-r--r--
yay fixed comments
     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.  This file may only be used 
     8  * or modified under the Terms and Conditions of its License Agreement, which is found 
     9  * in LICENSE.txt.  The Terms and Conditions for making SourceMod extensions/plugins 
    10  * may change at any time.  To view the latest information, see:
    11  *   http://www.sourcemod.net/license.php
    12  *
    13  * Version: $Id$
    14  */
    15 
    16 #if defined _sdktools_tempents_included
    17  #endinput
    18 #endif
    19 #define _sdktools_tempents_included
    20 
    21 /**
    22  * Called when a temp entity is going to be sent.
    23  *
    24  * @param te_name	TE name.
    25  * @param Players	Array containing target player indexes.
    26  * @param numClients	Number of players in the array.
    27  * @param delay		Delay in seconds to send the TE.
    28  * @return		Plugin_Continue to allow the transmission of the TE, Plugin_Stop to block it.
    29  */
    30 functag TEHook Action:public(const String:te_name[], const Players[], numClients, Float:delay);
    31 
    32 /**
    33  * Hooks a temp entity.
    34  *
    35  * @param te_name	TE name to hook.
    36  * @param hook		Function to use as a hook.
    37  * @noreturn
    38  * @error		Temp Entity name not available or invalid function hook.
    39  */
    40 native AddTempEntHook(const String:te_name[], TEHook:hook);
    41 
    42 /**
    43  * Removes a temp entity hook.
    44  *
    45  * @param te_name	TE name to unhook.
    46  * @param hook		Function used for the hook.
    47  * @noreturn
    48  * @error		Temp Entity name not available or invalid function hook.
    49  */
    50 native RemoveTempEntHook(const String:te_name[], TEHook:hook);
    51 
    52 /**
    53  * Starts a temp entity transmission.
    54  *
    55  * @param te_name	TE name.
    56  * @noreturn
    57  * @error		Temp Entity name not available.
    58  */
    59 native TE_Start(const String:te_name[]);
    60 
    61 /**
    62  * Checks if a certain TE property exists.
    63  *
    64  * @param prop		Property to use.
    65  * @return		True if the property exists, otherwise false.
    66  */
    67 native bool:TE_IsValidProp(const String:prop[]);
    68 
    69 /**
    70  * Sets an integer value in the current temp entity.
    71  *
    72  * @param prop		Property to use.
    73  * @param value		Integer value to set.
    74  * @noreturn
    75  * @error		Property not found.
    76  */
    77 native TE_WriteNum(const String:prop[], value);
    78 
    79 /**
    80  * Reads an integer value in the current temp entity.
    81  *
    82  * @param prop		Property to use.
    83  * @return		Property value.
    84  * @error		Property not found.
    85  */
    86 native TE_ReadNum(const String:prop[]);
    87 
    88 /**
    89  * Sets a floating point number in the current temp entity.
    90  *
    91  * @param prop		Property to use.
    92  * @param value		Floating point number to set.
    93  * @noreturn
    94  * @error		Property not found.
    95  */
    96 native TE_WriteFloat(const String:prop[], Float:value);
    97 
    98 /**
    99  * Reads a floating point number in the current temp entity.
   100  *
   101  * @param prop		Property to use.
   102  * @noreturn		Property value.
   103  * @error		Property not found.
   104  */
   105 native Float:TE_ReadFloat(const String:prop[]);
   106 
   107 /**
   108  * Sets a vector in the current temp entity.
   109  *
   110  * @param prop		Property to use.
   111  * @param vector	Vector to set.
   112  * @noreturn
   113  * @error		Property not found.
   114  */
   115 native TE_WriteVector(const String:prop[], const Float:vector[3]);
   116 
   117 /**
   118  * Reads a vector in the current temp entity.
   119  *
   120  * @param prop		Property to use.
   121  * @param vector	Vector to read.
   122  * @noreturn
   123  * @error		Property not found.
   124  */
   125 native TE_ReadVector(const String:prop[], Float:vector[3]);
   126 
   127 /**
   128  * Sets a QAngle in the current temp entity.
   129  *
   130  * @param prop		Property to use.
   131  * @param angles	Angles to set.
   132  * @return		True on success, otherwise false.
   133  * @error		Property not found.
   134  */
   135 native TE_WriteAngles(const String:prop[], const Float:angles[3]);
   136 
   137 /**
   138  * Sets an array of floats in the current temp entity.
   139  *
   140  * @param prop		Property to use.
   141  * @param array		Array of values to copy.
   142  * @param arraySize	Number of values to copy.
   143  * @return		True on success, otherwise false.
   144  * @error		Property not found.
   145  */
   146 native TE_WriteFloatArray(const String:prop[], const Float:array[], arraySize);
   147 
   148 /**
   149  * Sends the current temp entity to one or more clients.
   150  *
   151  * @param clients	Array containing player indexes to broadcast to.
   152  * @param numClients	Number of players in the array.
   153  * @param delay		Delay in seconds to send the TE.
   154  * @noreturn
   155  * @error		Invalid client index or client not in game.
   156  */
   157 native TE_Send(clients[], numClients, Float:delay=0.0);
   158 
   159 /**
   160  * Sets an encoded entity index in the current temp entity.
   161  * (This is usually used for m_nStartEntity and m_nEndEntity).
   162  *
   163  * @param prop		Property to use.
   164  * @param value		Value to set.
   165  * @noreturn
   166  * @error		Property not found.
   167  */
   168 stock TE_WriteEncodedEnt(const String:prop[], value)
   169 {
   170 	new encvalue = (value & 0x0FFF) | ((1 & 0xF)<<12);
   171 	return TE_WriteNum(prop, encvalue);
   172 }
   173 
   174 /**
   175  * Broadcasts the current temp entity to all clients.
   176  * @note See TE_Start().
   177  *
   178  * @param delay		Delay in seconds to send the TE.
   179  * @noreturn
   180  */
   181 stock TE_SendToAll(Float:delay=0.0)
   182 {
   183 	new maxClients = GetMaxClients();
   184 	new total = 0;
   185 	new clients[maxClients];
   186 	for (new i=1; i<=maxClients; i++)
   187 	{
   188 		if (IsClientInGame(i))
   189 		{
   190 			clients[total++] = i;
   191 		}
   192 	}
   193 	return TE_Send(clients, total, delay);
   194 }
   195 
   196 /**
   197  * Sends the current TE to only a client.
   198  * @note See TE_Start().
   199  *
   200  * @param client	Client to send to.
   201  * @param delay		Delay in seconds to send the TE.
   202  * @noreturn
   203  * @error		Invalid client index or client not in game.
   204  */
   205 stock TE_SendToClient(client, Float:delay=0.0)
   206 {
   207 	new players[1];
   208 
   209 	players[0] = client;
   210 
   211 	return TE_Send(players, 1, delay);
   212 }