|
ds@1952
|
1 |
/** |
|
ds@1952
|
2 |
* vim: set ts=4 : |
|
ds@1952
|
3 |
* ============================================================================= |
|
ds@1952
|
4 |
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved. |
|
ds@1952
|
5 |
* ============================================================================= |
|
ds@1952
|
6 |
* |
|
ds@1952
|
7 |
* This file is part of the SourceMod/SourcePawn SDK. |
|
ds@1952
|
8 |
* |
|
ds@1952
|
9 |
* This program is free software; you can redistribute it and/or modify it under |
|
ds@1952
|
10 |
* the terms of the GNU General Public License, version 3.0, as published by the |
|
ds@1952
|
11 |
* Free Software Foundation. |
|
ds@1952
|
12 |
* |
|
ds@1952
|
13 |
* This program is distributed in the hope that it will be useful, but WITHOUT |
|
ds@1952
|
14 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
ds@1952
|
15 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
|
ds@1952
|
16 |
* details. |
|
ds@1952
|
17 |
* |
|
ds@1952
|
18 |
* You should have received a copy of the GNU General Public License along with |
|
ds@1952
|
19 |
* this program. If not, see <http://www.gnu.org/licenses/>. |
|
ds@1952
|
20 |
* |
|
ds@1952
|
21 |
* As a special exception, AlliedModders LLC gives you permission to link the |
|
ds@1952
|
22 |
* code of this program (as well as its derivative works) to "Half-Life 2," the |
|
ds@1952
|
23 |
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software |
|
ds@1952
|
24 |
* by the Valve Corporation. You must obey the GNU General Public License in |
|
ds@1952
|
25 |
* all respects for all other code used. Additionally, AlliedModders LLC grants |
|
ds@1952
|
26 |
* this exception to all derivative works. AlliedModders LLC defines further |
|
ds@1952
|
27 |
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), |
|
ds@1952
|
28 |
* or <http://www.sourcemod.net/license.php>. |
|
ds@1952
|
29 |
* |
|
ds@1952
|
30 |
* Version: $Id$ |
|
ds@1952
|
31 |
*/ |
|
ds@1952
|
32 |
|
|
ds@1952
|
33 |
#if defined _events_included |
|
ds@1952
|
34 |
#endinput |
|
ds@1952
|
35 |
#endif |
|
ds@1952
|
36 |
#define _events_included |
|
ds@1952
|
37 |
|
|
ds@1952
|
38 |
/** |
|
ds@1952
|
39 |
* Event hook modes determining how hooking should be handled |
|
ds@1952
|
40 |
*/ |
|
ds@1952
|
41 |
enum EventHookMode |
|
ds@1952
|
42 |
{ |
|
ds@1952
|
43 |
EventHookMode_Pre, /**< Hook callback fired before event is fired */ |
|
ds@1952
|
44 |
EventHookMode_Post, /**< Hook callback fired after event is fired */ |
|
ds@1952
|
45 |
EventHookMode_PostNoCopy /**< Hook callback fired after event is fired, but event data won't be copied */ |
|
ds@1952
|
46 |
}; |
|
ds@1952
|
47 |
|
|
ds@1952
|
48 |
/** |
|
ds@1952
|
49 |
* Hook function types for events. |
|
ds@1952
|
50 |
*/ |
|
ds@1952
|
51 |
funcenum EventHook |
|
ds@1952
|
52 |
{ |
|
ds@1952
|
53 |
/** |
|
ds@1952
|
54 |
* Called when a game event is fired. |
|
ds@1952
|
55 |
* |
|
ds@1952
|
56 |
* @param event Handle to event. This could be INVALID_HANDLE if every plugin hooking |
|
ds@1952
|
57 |
* this event has set the hook mode EventHookMode_PostNoCopy. |
|
ds@1952
|
58 |
* @param name String containing the name of the event. |
|
ds@1952
|
59 |
* @param dontBroadcast True if event was not broadcast to clients, false otherwise. |
|
ds@1952
|
60 |
* @return Ignored for post hooks. Plugin_Handled will block event if hooked as pre. |
|
ds@1952
|
61 |
*/ |
|
ds@1952
|
62 |
Action:public(Handle:event, const String:name[], bool:dontBroadcast), |
|
ds@1952
|
63 |
/** |
|
ds@1952
|
64 |
* Called when a game event is fired. |
|
ds@1952
|
65 |
* |
|
ds@1952
|
66 |
* @param event Handle to event. This could be INVALID_HANDLE if every plugin hooking |
|
ds@1952
|
67 |
* this event has set the hook mode EventHookMode_PostNoCopy. |
|
ds@1952
|
68 |
* @param name String containing the name of the event. |
|
ds@1952
|
69 |
* @param dontBroadcast True if event was not broadcast to clients, false otherwise. |
|
ds@1952
|
70 |
* @noreturn |
|
ds@1952
|
71 |
*/ |
|
ds@1952
|
72 |
public(Handle:event, const String:name[], bool:dontBroadcast), |
|
ds@1952
|
73 |
}; |
|
ds@1952
|
74 |
|
|
ds@1952
|
75 |
/** |
|
ds@1952
|
76 |
* Creates a hook for when a game event is fired. |
|
ds@1952
|
77 |
* |
|
ds@1952
|
78 |
* @param name Name of event. |
|
ds@1952
|
79 |
* @param callback An EventHook function pointer. |
|
ds@1952
|
80 |
* @param mode Optional EventHookMode determining the type of hook. |
|
ds@1952
|
81 |
* @noreturn |
|
ds@1952
|
82 |
* @error Invalid event name or invalid callback function. |
|
ds@1952
|
83 |
*/ |
|
ds@1952
|
84 |
native HookEvent(const String:name[], EventHook:callback, EventHookMode:mode=EventHookMode_Post); |
|
ds@1952
|
85 |
|
|
ds@1952
|
86 |
/** |
|
ds@1952
|
87 |
* Creates a hook for when a game event is fired. |
|
ds@1952
|
88 |
* |
|
ds@1952
|
89 |
* @param name Name of event. |
|
ds@1952
|
90 |
* @param callback An EventHook function pointer. |
|
ds@1952
|
91 |
* @param mode Optional EventHookMode determining the type of hook. |
|
ds@1952
|
92 |
* @return True if event exists and was hooked successfully, false otherwise. |
|
ds@1952
|
93 |
* @error Invalid callback function. |
|
ds@1952
|
94 |
*/ |
|
ds@1952
|
95 |
native bool:HookEventEx(const String:name[], EventHook:callback, EventHookMode:mode=EventHookMode_Post); |
|
ds@1952
|
96 |
|
|
ds@1952
|
97 |
/** |
|
ds@1952
|
98 |
* Removes a hook for when a game event is fired. |
|
ds@1952
|
99 |
* |
|
ds@1952
|
100 |
* @param name Name of event. |
|
ds@1952
|
101 |
* @param callback An EventHook function pointer. |
|
ds@1952
|
102 |
* @param mode Optional EventHookMode determining the type of hook. |
|
ds@1952
|
103 |
* @noreturn |
|
ds@1952
|
104 |
* @error Invalid callback function or no active hook for specified event. |
|
ds@1952
|
105 |
*/ |
|
ds@1952
|
106 |
native UnhookEvent(const String:name[], EventHook:callback, EventHookMode:mode=EventHookMode_Post); |
|
ds@1952
|
107 |
|
|
ds@1952
|
108 |
/** |
|
ds@1952
|
109 |
* Creates a game event to be fired later. |
|
ds@1952
|
110 |
* |
|
ds@1952
|
111 |
* The Handle should not be closed via CloseHandle(). It must be closed via |
|
ds@1952
|
112 |
* FireEvent() or CancelCreatedEvent(). |
|
ds@1952
|
113 |
* |
|
ds@1952
|
114 |
* @param name Name of event. |
|
ds@1952
|
115 |
* @param force If set to true, this forces the event to be created even if it's not being hooked. |
|
ds@1952
|
116 |
* Note that this will not force it if the event doesn't exist at all. |
|
ds@1952
|
117 |
* @return Handle to event. INVALID_HANDLE is returned if the event doesn't exist or isn't |
|
ds@1952
|
118 |
being hooked (unless force is true). |
|
ds@1952
|
119 |
*/ |
|
ds@1952
|
120 |
native Handle:CreateEvent(const String:name[], bool:force=false); |
|
ds@1952
|
121 |
|
|
ds@1952
|
122 |
/** |
|
ds@1952
|
123 |
* Fires a game event. |
|
ds@1952
|
124 |
* |
|
ds@1952
|
125 |
* This function closes the event Handle after completing. |
|
ds@1952
|
126 |
* |
|
ds@1952
|
127 |
* @param event Handle to the event. |
|
ds@1952
|
128 |
* @param dontBroadcast Optional boolean that determines if event should be broadcast to clients. |
|
ds@1952
|
129 |
* @noreturn |
|
ds@1952
|
130 |
* @error Invalid or corrupt Handle. |
|
ds@1952
|
131 |
*/ |
|
ds@1952
|
132 |
native FireEvent(Handle:event, bool:dontBroadcast=false); |
|
ds@1952
|
133 |
|
|
ds@1952
|
134 |
/** |
|
ds@1952
|
135 |
* Cancels a previously created game event that has not been fired. |
|
ds@1952
|
136 |
* |
|
ds@1952
|
137 |
* @param event Handled to the event. |
|
ds@1952
|
138 |
* @noreturn |
|
ds@1952
|
139 |
* @error Invalid or corrupt Handle. |
|
ds@1952
|
140 |
*/ |
|
ds@1952
|
141 |
native CancelCreatedEvent(Handle:event); |
|
ds@1952
|
142 |
|
|
ds@1952
|
143 |
/** |
|
ds@1952
|
144 |
* Returns the boolean value of a game event's key. |
|
ds@1952
|
145 |
* |
|
ds@1952
|
146 |
* @param event Handle to the event. |
|
ds@1952
|
147 |
* @param key Name of event key. |
|
ds@1952
|
148 |
* @return The boolean value of the specfied event key. |
|
ds@1952
|
149 |
* @error Invalid or corrupt Handle. |
|
ds@1952
|
150 |
*/ |
|
ds@1952
|
151 |
native bool:GetEventBool(Handle:event, const String:key[]); |
|
ds@1952
|
152 |
|
|
ds@1952
|
153 |
/** |
|
ds@1952
|
154 |
* Sets the boolean value of a game event's key. |
|
ds@1952
|
155 |
* |
|
ds@1952
|
156 |
* @param event Handle to the event. |
|
ds@1952
|
157 |
* @param key Name of event key. |
|
ds@1952
|
158 |
* @param value New boolean value. |
|
ds@1952
|
159 |
* @noreturn |
|
ds@1952
|
160 |
* @error Invalid or corrupt Handle. |
|
ds@1952
|
161 |
*/ |
|
ds@1952
|
162 |
native SetEventBool(Handle:event, const String:key[], bool:value); |
|
ds@1952
|
163 |
|
|
ds@1952
|
164 |
/** |
|
ds@1952
|
165 |
* Returns the integer value of a game event's key. |
|
ds@1952
|
166 |
* |
|
ds@1952
|
167 |
* @param event Handle to the event. |
|
ds@1952
|
168 |
* @param key Name of event key. |
|
ds@1952
|
169 |
* @return The integer value of the specfied event key. |
|
ds@1952
|
170 |
* @error Invalid or corrupt Handle. |
|
ds@1952
|
171 |
*/ |
|
ds@1952
|
172 |
native GetEventInt(Handle:event, const String:key[]); |
|
ds@1952
|
173 |
|
|
ds@1952
|
174 |
/** |
|
ds@1952
|
175 |
* Sets the integer value of a game event's key. |
|
ds@1952
|
176 |
* |
|
ds@1952
|
177 |
* Integer value refers to anything that can be reduced to an integer. |
|
ds@1952
|
178 |
* The various size specifiers, such as "byte" and "short" are still |
|
ds@1952
|
179 |
* integers, and only refer to how much data will actually be sent |
|
ds@1952
|
180 |
* over the network (if applicable). |
|
ds@1952
|
181 |
* |
|
ds@1952
|
182 |
* @param event Handle to the event. |
|
ds@1952
|
183 |
* @param key Name of event key. |
|
ds@1952
|
184 |
* @param value New integer value. |
|
ds@1952
|
185 |
* @noreturn |
|
ds@1952
|
186 |
* @error Invalid or corrupt Handle. |
|
ds@1952
|
187 |
*/ |
|
ds@1952
|
188 |
native SetEventInt(Handle:event, const String:key[], value); |
|
ds@1952
|
189 |
|
|
ds@1952
|
190 |
/** |
|
ds@1952
|
191 |
* Returns the floating point value of a game event's key. |
|
ds@1952
|
192 |
* |
|
ds@1952
|
193 |
* @param event Handle to the event. |
|
ds@1952
|
194 |
* @param key Name of event key. |
|
ds@1952
|
195 |
* @return The floating point value of the specfied event key. |
|
ds@1952
|
196 |
* @error Invalid or corrupt Handle. |
|
ds@1952
|
197 |
*/ |
|
ds@1952
|
198 |
native Float:GetEventFloat(Handle:event, const String:key[]); |
|
ds@1952
|
199 |
|
|
ds@1952
|
200 |
/** |
|
ds@1952
|
201 |
* Sets the floating point value of a game event's key. |
|
ds@1952
|
202 |
* |
|
ds@1952
|
203 |
* @param event Handle to the event. |
|
ds@1952
|
204 |
* @param key Name of event key. |
|
ds@1952
|
205 |
* @param value New floating point value. |
|
ds@1952
|
206 |
* @noreturn |
|
ds@1952
|
207 |
* @error Invalid or corrupt Handle. |
|
ds@1952
|
208 |
*/ |
|
ds@1952
|
209 |
native SetEventFloat(Handle:event, const String:key[], Float:value); |
|
ds@1952
|
210 |
|
|
ds@1952
|
211 |
/** |
|
ds@1952
|
212 |
* Retrieves the string value of a game event's key. |
|
ds@1952
|
213 |
* |
|
ds@1952
|
214 |
* @param event Handle to the event. |
|
ds@1952
|
215 |
* @param key Name of event key. |
|
ds@1952
|
216 |
* @param value Buffer to store the value of the specified event key. |
|
ds@1952
|
217 |
* @param maxlength Maximum length of string buffer. |
|
ds@1952
|
218 |
* @noreturn |
|
ds@1952
|
219 |
* @error Invalid or corrupt Handle. |
|
ds@1952
|
220 |
*/ |
|
ds@1952
|
221 |
native GetEventString(Handle:event, const String:key[], String:value[], maxlength); |
|
ds@1952
|
222 |
|
|
ds@1952
|
223 |
/** |
|
ds@1952
|
224 |
* Sets the string value of a game event's key. |
|
ds@1952
|
225 |
* |
|
ds@1952
|
226 |
* @param event Handle to the event. |
|
ds@1952
|
227 |
* @param key Name of event key. |
|
ds@1952
|
228 |
* @param value New string value. |
|
ds@1952
|
229 |
* @noreturn |
|
ds@1952
|
230 |
* @error Invalid or corrupt Handle. |
|
ds@1952
|
231 |
*/ |
|
ds@1952
|
232 |
native SetEventString(Handle:event, const String:key[], const String:value[]); |
|
ds@1952
|
233 |
|
|
ds@1952
|
234 |
/** |
|
ds@1952
|
235 |
* Retrieves the name of a game event. |
|
ds@1952
|
236 |
* |
|
ds@1952
|
237 |
* @param event Handle to the event. |
|
ds@1952
|
238 |
* @param value Buffer to store the name of the event. |
|
ds@1952
|
239 |
* @param maxlength Maximum length of string buffer. |
|
ds@1952
|
240 |
* @noreturn |
|
ds@1952
|
241 |
* @error Invalid or corrupt Handle. |
|
ds@1952
|
242 |
*/ |
|
ds@1952
|
243 |
native GetEventName(Handle:event, String:name[], maxlength); |