|
faluco@1031
|
1 |
/** |
|
faluco@1031
|
2 |
* vim: set ts=4 : |
|
ds@1330
|
3 |
* ============================================================================= |
|
ds@1947
|
4 |
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved. |
|
ds@1330
|
5 |
* ============================================================================= |
|
ds@1330
|
6 |
* |
|
ds@1330
|
7 |
* This file is part of the SourceMod/SourcePawn SDK. |
|
faluco@1031
|
8 |
* |
|
ds@1330
|
9 |
* This program is free software; you can redistribute it and/or modify it under |
|
ds@1330
|
10 |
* the terms of the GNU General Public License, version 3.0, as published by the |
|
ds@1330
|
11 |
* Free Software Foundation. |
|
ds@1330
|
12 |
* |
|
ds@1330
|
13 |
* This program is distributed in the hope that it will be useful, but WITHOUT |
|
ds@1330
|
14 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
ds@1330
|
15 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
|
ds@1330
|
16 |
* details. |
|
ds@1330
|
17 |
* |
|
ds@1330
|
18 |
* You should have received a copy of the GNU General Public License along with |
|
ds@1330
|
19 |
* this program. If not, see <http://www.gnu.org/licenses/>. |
|
ds@1330
|
20 |
* |
|
ds@1330
|
21 |
* As a special exception, AlliedModders LLC gives you permission to link the |
|
ds@1330
|
22 |
* code of this program (as well as its derivative works) to "Half-Life 2," the |
|
ds@1330
|
23 |
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software |
|
ds@1330
|
24 |
* by the Valve Corporation. You must obey the GNU General Public License in |
|
ds@1330
|
25 |
* all respects for all other code used. Additionally, AlliedModders LLC grants |
|
ds@1330
|
26 |
* this exception to all derivative works. AlliedModders LLC defines further |
|
ds@1330
|
27 |
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), |
|
ds@1330
|
28 |
* or <http://www.sourcemod.net/license.php>. |
|
faluco@1031
|
29 |
* |
|
faluco@1031
|
30 |
* Version: $Id$ |
|
faluco@1031
|
31 |
*/ |
|
faluco@1031
|
32 |
|
|
faluco@1031
|
33 |
#if defined _sdktools_tempents_included |
|
faluco@1031
|
34 |
#endinput |
|
faluco@1031
|
35 |
#endif |
|
faluco@1031
|
36 |
#define _sdktools_tempents_included |
|
faluco@1031
|
37 |
|
|
faluco@1031
|
38 |
/** |
|
faluco@1255
|
39 |
* Called when a temp entity is going to be sent. |
|
faluco@1255
|
40 |
* |
|
faluco@1255
|
41 |
* @param te_name TE name. |
|
faluco@1255
|
42 |
* @param Players Array containing target player indexes. |
|
faluco@1255
|
43 |
* @param numClients Number of players in the array. |
|
faluco@1255
|
44 |
* @param delay Delay in seconds to send the TE. |
|
faluco@1255
|
45 |
* @return Plugin_Continue to allow the transmission of the TE, Plugin_Stop to block it. |
|
faluco@1255
|
46 |
*/ |
|
dvander@2317
|
47 |
functag public Action:TEHook(const String:te_name[], const Players[], numClients, Float:delay); |
|
faluco@1255
|
48 |
|
|
faluco@1255
|
49 |
/** |
|
faluco@1255
|
50 |
* Hooks a temp entity. |
|
faluco@1255
|
51 |
* |
|
faluco@1255
|
52 |
* @param te_name TE name to hook. |
|
faluco@1255
|
53 |
* @param hook Function to use as a hook. |
|
faluco@1255
|
54 |
* @noreturn |
|
faluco@1255
|
55 |
* @error Temp Entity name not available or invalid function hook. |
|
faluco@1255
|
56 |
*/ |
|
faluco@1255
|
57 |
native AddTempEntHook(const String:te_name[], TEHook:hook); |
|
faluco@1255
|
58 |
|
|
faluco@1255
|
59 |
/** |
|
faluco@1256
|
60 |
* Removes a temp entity hook. |
|
faluco@1255
|
61 |
* |
|
faluco@1255
|
62 |
* @param te_name TE name to unhook. |
|
faluco@1255
|
63 |
* @param hook Function used for the hook. |
|
faluco@1255
|
64 |
* @noreturn |
|
faluco@1255
|
65 |
* @error Temp Entity name not available or invalid function hook. |
|
faluco@1255
|
66 |
*/ |
|
faluco@1255
|
67 |
native RemoveTempEntHook(const String:te_name[], TEHook:hook); |
|
faluco@1255
|
68 |
|
|
faluco@1255
|
69 |
/** |
|
faluco@1031
|
70 |
* Starts a temp entity transmission. |
|
faluco@1031
|
71 |
* |
|
faluco@1031
|
72 |
* @param te_name TE name. |
|
faluco@1031
|
73 |
* @noreturn |
|
faluco@1031
|
74 |
* @error Temp Entity name not available. |
|
faluco@1031
|
75 |
*/ |
|
faluco@1031
|
76 |
native TE_Start(const String:te_name[]); |
|
faluco@1031
|
77 |
|
|
faluco@1031
|
78 |
/** |
|
faluco@1031
|
79 |
* Checks if a certain TE property exists. |
|
faluco@1031
|
80 |
* |
|
faluco@1031
|
81 |
* @param prop Property to use. |
|
faluco@1031
|
82 |
* @return True if the property exists, otherwise false. |
|
faluco@1031
|
83 |
*/ |
|
faluco@1031
|
84 |
native bool:TE_IsValidProp(const String:prop[]); |
|
faluco@1031
|
85 |
|
|
faluco@1031
|
86 |
/** |
|
faluco@1031
|
87 |
* Sets an integer value in the current temp entity. |
|
faluco@1031
|
88 |
* |
|
faluco@1031
|
89 |
* @param prop Property to use. |
|
faluco@1031
|
90 |
* @param value Integer value to set. |
|
faluco@1031
|
91 |
* @noreturn |
|
faluco@1031
|
92 |
* @error Property not found. |
|
faluco@1031
|
93 |
*/ |
|
faluco@1031
|
94 |
native TE_WriteNum(const String:prop[], value); |
|
faluco@1031
|
95 |
|
|
faluco@1031
|
96 |
/** |
|
faluco@1255
|
97 |
* Reads an integer value in the current temp entity. |
|
faluco@1255
|
98 |
* |
|
faluco@1255
|
99 |
* @param prop Property to use. |
|
faluco@1255
|
100 |
* @return Property value. |
|
faluco@1255
|
101 |
* @error Property not found. |
|
faluco@1255
|
102 |
*/ |
|
faluco@1255
|
103 |
native TE_ReadNum(const String:prop[]); |
|
faluco@1255
|
104 |
|
|
faluco@1255
|
105 |
/** |
|
faluco@1031
|
106 |
* Sets a floating point number in the current temp entity. |
|
faluco@1031
|
107 |
* |
|
faluco@1031
|
108 |
* @param prop Property to use. |
|
faluco@1031
|
109 |
* @param value Floating point number to set. |
|
faluco@1031
|
110 |
* @noreturn |
|
faluco@1031
|
111 |
* @error Property not found. |
|
faluco@1031
|
112 |
*/ |
|
faluco@1031
|
113 |
native TE_WriteFloat(const String:prop[], Float:value); |
|
faluco@1031
|
114 |
|
|
faluco@1031
|
115 |
/** |
|
faluco@1255
|
116 |
* Reads a floating point number in the current temp entity. |
|
faluco@1255
|
117 |
* |
|
faluco@1255
|
118 |
* @param prop Property to use. |
|
faluco@1255
|
119 |
* @noreturn Property value. |
|
faluco@1255
|
120 |
* @error Property not found. |
|
faluco@1255
|
121 |
*/ |
|
faluco@1255
|
122 |
native Float:TE_ReadFloat(const String:prop[]); |
|
faluco@1255
|
123 |
|
|
faluco@1255
|
124 |
/** |
|
faluco@1031
|
125 |
* Sets a vector in the current temp entity. |
|
faluco@1031
|
126 |
* |
|
faluco@1031
|
127 |
* @param prop Property to use. |
|
faluco@1031
|
128 |
* @param vector Vector to set. |
|
faluco@1031
|
129 |
* @noreturn |
|
faluco@1031
|
130 |
* @error Property not found. |
|
faluco@1031
|
131 |
*/ |
|
faluco@1039
|
132 |
native TE_WriteVector(const String:prop[], const Float:vector[3]); |
|
faluco@1031
|
133 |
|
|
faluco@1031
|
134 |
/** |
|
faluco@1255
|
135 |
* Reads a vector in the current temp entity. |
|
faluco@1255
|
136 |
* |
|
faluco@1255
|
137 |
* @param prop Property to use. |
|
faluco@1255
|
138 |
* @param vector Vector to read. |
|
faluco@1255
|
139 |
* @noreturn |
|
faluco@1255
|
140 |
* @error Property not found. |
|
faluco@1255
|
141 |
*/ |
|
faluco@1255
|
142 |
native TE_ReadVector(const String:prop[], Float:vector[3]); |
|
faluco@1255
|
143 |
|
|
faluco@1255
|
144 |
/** |
|
faluco@1031
|
145 |
* Sets a QAngle in the current temp entity. |
|
faluco@1031
|
146 |
* |
|
faluco@1031
|
147 |
* @param prop Property to use. |
|
faluco@1031
|
148 |
* @param angles Angles to set. |
|
faluco@1031
|
149 |
* @return True on success, otherwise false. |
|
faluco@1031
|
150 |
* @error Property not found. |
|
faluco@1031
|
151 |
*/ |
|
faluco@1039
|
152 |
native TE_WriteAngles(const String:prop[], const Float:angles[3]); |
|
faluco@1039
|
153 |
|
|
faluco@1039
|
154 |
/** |
|
faluco@1039
|
155 |
* Sets an array of floats in the current temp entity. |
|
faluco@1039
|
156 |
* |
|
faluco@1039
|
157 |
* @param prop Property to use. |
|
faluco@1039
|
158 |
* @param array Array of values to copy. |
|
faluco@1039
|
159 |
* @param arraySize Number of values to copy. |
|
faluco@1039
|
160 |
* @return True on success, otherwise false. |
|
faluco@1039
|
161 |
* @error Property not found. |
|
faluco@1039
|
162 |
*/ |
|
faluco@1039
|
163 |
native TE_WriteFloatArray(const String:prop[], const Float:array[], arraySize); |
|
faluco@1031
|
164 |
|
|
faluco@1031
|
165 |
/** |
|
faluco@1031
|
166 |
* Sends the current temp entity to one or more clients. |
|
faluco@1031
|
167 |
* |
|
faluco@1031
|
168 |
* @param clients Array containing player indexes to broadcast to. |
|
faluco@1031
|
169 |
* @param numClients Number of players in the array. |
|
faluco@1031
|
170 |
* @param delay Delay in seconds to send the TE. |
|
faluco@1031
|
171 |
* @noreturn |
|
faluco@1031
|
172 |
* @error Invalid client index or client not in game. |
|
faluco@1031
|
173 |
*/ |
|
faluco@1031
|
174 |
native TE_Send(clients[], numClients, Float:delay=0.0); |
|
faluco@1031
|
175 |
|
|
faluco@1031
|
176 |
/** |
|
faluco@1031
|
177 |
* Sets an encoded entity index in the current temp entity. |
|
faluco@1031
|
178 |
* (This is usually used for m_nStartEntity and m_nEndEntity). |
|
faluco@1031
|
179 |
* |
|
faluco@1031
|
180 |
* @param prop Property to use. |
|
faluco@1031
|
181 |
* @param value Value to set. |
|
faluco@1031
|
182 |
* @noreturn |
|
faluco@1031
|
183 |
* @error Property not found. |
|
faluco@1031
|
184 |
*/ |
|
faluco@1031
|
185 |
stock TE_WriteEncodedEnt(const String:prop[], value) |
|
faluco@1031
|
186 |
{ |
|
faluco@1031
|
187 |
new encvalue = (value & 0x0FFF) | ((1 & 0xF)<<12); |
|
faluco@1031
|
188 |
return TE_WriteNum(prop, encvalue); |
|
faluco@1031
|
189 |
} |
|
faluco@1031
|
190 |
|
|
faluco@1031
|
191 |
/** |
|
faluco@1031
|
192 |
* Broadcasts the current temp entity to all clients. |
|
faluco@1031
|
193 |
* @note See TE_Start(). |
|
faluco@1031
|
194 |
* |
|
faluco@1031
|
195 |
* @param delay Delay in seconds to send the TE. |
|
faluco@1031
|
196 |
* @noreturn |
|
faluco@1031
|
197 |
*/ |
|
faluco@1031
|
198 |
stock TE_SendToAll(Float:delay=0.0) |
|
faluco@1031
|
199 |
{ |
|
faluco@1031
|
200 |
new maxClients = GetMaxClients(); |
|
faluco@1031
|
201 |
new total = 0; |
|
faluco@1031
|
202 |
new clients[maxClients]; |
|
faluco@1031
|
203 |
for (new i=1; i<=maxClients; i++) |
|
faluco@1031
|
204 |
{ |
|
faluco@1031
|
205 |
if (IsClientInGame(i)) |
|
faluco@1031
|
206 |
{ |
|
faluco@1031
|
207 |
clients[total++] = i; |
|
faluco@1031
|
208 |
} |
|
faluco@1031
|
209 |
} |
|
faluco@1031
|
210 |
return TE_Send(clients, total, delay); |
|
faluco@1031
|
211 |
} |
|
faluco@1031
|
212 |
|
|
faluco@1031
|
213 |
/** |
|
faluco@1031
|
214 |
* Sends the current TE to only a client. |
|
faluco@1031
|
215 |
* @note See TE_Start(). |
|
faluco@1031
|
216 |
* |
|
faluco@1031
|
217 |
* @param client Client to send to. |
|
faluco@1031
|
218 |
* @param delay Delay in seconds to send the TE. |
|
faluco@1031
|
219 |
* @noreturn |
|
faluco@1031
|
220 |
* @error Invalid client index or client not in game. |
|
faluco@1031
|
221 |
*/ |
|
dvander@1053
|
222 |
stock TE_SendToClient(client, Float:delay=0.0) |
|
faluco@1031
|
223 |
{ |
|
faluco@1031
|
224 |
new players[1]; |
|
faluco@1031
|
225 |
|
|
faluco@1031
|
226 |
players[0] = client; |
|
faluco@1031
|
227 |
|
|
faluco@1031
|
228 |
return TE_Send(players, 1, delay); |
|
faluco@1031
|
229 |
} |