3 * ===============================================================
4 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
5 * ===============================================================
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
16 #if defined _sdktools_tempents_included
19 #define _sdktools_tempents_included
22 * Called when a temp entity is going to be sent.
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.
30 functag TEHook Action:public(const String:te_name[], const Players[], numClients, Float:delay);
33 * Hooks a temp entity.
35 * @param te_name TE name to hook.
36 * @param hook Function to use as a hook.
38 * @error Temp Entity name not available or invalid function hook.
40 native AddTempEntHook(const String:te_name[], TEHook:hook);
43 * Removes a temp entity hook.
45 * @param te_name TE name to unhook.
46 * @param hook Function used for the hook.
48 * @error Temp Entity name not available or invalid function hook.
50 native RemoveTempEntHook(const String:te_name[], TEHook:hook);
53 * Starts a temp entity transmission.
55 * @param te_name TE name.
57 * @error Temp Entity name not available.
59 native TE_Start(const String:te_name[]);
62 * Checks if a certain TE property exists.
64 * @param prop Property to use.
65 * @return True if the property exists, otherwise false.
67 native bool:TE_IsValidProp(const String:prop[]);
70 * Sets an integer value in the current temp entity.
72 * @param prop Property to use.
73 * @param value Integer value to set.
75 * @error Property not found.
77 native TE_WriteNum(const String:prop[], value);
80 * Reads an integer value in the current temp entity.
82 * @param prop Property to use.
83 * @return Property value.
84 * @error Property not found.
86 native TE_ReadNum(const String:prop[]);
89 * Sets a floating point number in the current temp entity.
91 * @param prop Property to use.
92 * @param value Floating point number to set.
94 * @error Property not found.
96 native TE_WriteFloat(const String:prop[], Float:value);
99 * Reads a floating point number in the current temp entity.
101 * @param prop Property to use.
102 * @noreturn Property value.
103 * @error Property not found.
105 native Float:TE_ReadFloat(const String:prop[]);
108 * Sets a vector in the current temp entity.
110 * @param prop Property to use.
111 * @param vector Vector to set.
113 * @error Property not found.
115 native TE_WriteVector(const String:prop[], const Float:vector[3]);
118 * Reads a vector in the current temp entity.
120 * @param prop Property to use.
121 * @param vector Vector to read.
123 * @error Property not found.
125 native TE_ReadVector(const String:prop[], Float:vector[3]);
128 * Sets a QAngle in the current temp entity.
130 * @param prop Property to use.
131 * @param angles Angles to set.
132 * @return True on success, otherwise false.
133 * @error Property not found.
135 native TE_WriteAngles(const String:prop[], const Float:angles[3]);
138 * Sets an array of floats in the current temp entity.
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.
146 native TE_WriteFloatArray(const String:prop[], const Float:array[], arraySize);
149 * Sends the current temp entity to one or more clients.
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.
155 * @error Invalid client index or client not in game.
157 native TE_Send(clients[], numClients, Float:delay=0.0);
160 * Sets an encoded entity index in the current temp entity.
161 * (This is usually used for m_nStartEntity and m_nEndEntity).
163 * @param prop Property to use.
164 * @param value Value to set.
166 * @error Property not found.
168 stock TE_WriteEncodedEnt(const String:prop[], value)
170 new encvalue = (value & 0x0FFF) | ((1 & 0xF)<<12);
171 return TE_WriteNum(prop, encvalue);
175 * Broadcasts the current temp entity to all clients.
176 * @note See TE_Start().
178 * @param delay Delay in seconds to send the TE.
181 stock TE_SendToAll(Float:delay=0.0)
183 new maxClients = GetMaxClients();
185 new clients[maxClients];
186 for (new i=1; i<=maxClients; i++)
188 if (IsClientInGame(i))
190 clients[total++] = i;
193 return TE_Send(clients, total, delay);
197 * Sends the current TE to only a client.
198 * @note See TE_Start().
200 * @param client Client to send to.
201 * @param delay Delay in seconds to send the TE.
203 * @error Invalid client index or client not in game.
205 stock TE_SendToClient(client, Float:delay=0.0)
211 return TE_Send(players, 1, delay);