|
ds@576
|
1 |
/** |
|
ds@576
|
2 |
* vim: set ts=4 : |
|
ds@576
|
3 |
* =============================================================== |
|
ds@576
|
4 |
* SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved. |
|
ds@576
|
5 |
* =============================================================== |
|
ds@576
|
6 |
* |
|
ds@576
|
7 |
* This file is part of the SourceMod/SourcePawn SDK. This file may only be used |
|
ds@576
|
8 |
* or modified under the Terms and Conditions of its License Agreement, which is found |
|
ds@576
|
9 |
* in LICENSE.txt. The Terms and Conditions for making SourceMod extensions/plugins |
|
ds@576
|
10 |
* may change at any time. To view the latest information, see: |
|
ds@576
|
11 |
* http://www.sourcemod.net/license.php |
|
ds@576
|
12 |
* |
|
ds@576
|
13 |
* Version: $Id$ |
|
ds@576
|
14 |
*/ |
|
ds@576
|
15 |
|
|
ds@576
|
16 |
#if defined _events_included |
|
ds@576
|
17 |
#endinput |
|
ds@576
|
18 |
#endif |
|
ds@576
|
19 |
#define _events_included |
|
ds@576
|
20 |
|
|
ds@576
|
21 |
/** |
|
ds@576
|
22 |
* Event hook modes determining how hooking should be handled |
|
ds@576
|
23 |
*/ |
|
ds@576
|
24 |
enum EventHookMode |
|
ds@576
|
25 |
{ |
|
ds@576
|
26 |
EventHookMode_Pre, /**< Hook callback fired before event is fired */ |
|
ds@576
|
27 |
EventHookMode_Post, /**< Hook callback fired after event is fired */ |
|
ds@576
|
28 |
EventHookMode_PostNoCopy /**< Hook callback fired after event is fired, but event data won't be copied */ |
|
ds@576
|
29 |
}; |
|
ds@576
|
30 |
|
|
dvander@619
|
31 |
/** |
|
dvander@619
|
32 |
* Hook function types for events. |
|
dvander@619
|
33 |
*/ |
|
ds@576
|
34 |
funcenum EventHook |
|
ds@576
|
35 |
{ |
|
ds@576
|
36 |
/** |
|
ds@576
|
37 |
* Called when a game event is fired. |
|
ds@576
|
38 |
* |
|
ds@576
|
39 |
* @param event Handle to event. This could be INVALID_HANDLE if every plugin hooking |
|
ds@576
|
40 |
* this event has set the hook mode EventHookMode_PostNoCopy. |
|
ds@576
|
41 |
* @param name String containing the name of the event. |
|
ds@576
|
42 |
* @param dontBroadcast True if event was not broadcast to clients, false otherwise. |
|
ds@576
|
43 |
* @return Ignored for post hooks. Plugin_Handled will block event if hooked as pre. |
|
ds@576
|
44 |
*/ |
|
ds@576
|
45 |
Action:public(Handle:event, const String:name[], bool:dontBroadcast), |
|
ds@576
|
46 |
/** |
|
ds@576
|
47 |
* Called when a game event is fired. |
|
ds@576
|
48 |
* |
|
ds@576
|
49 |
* @param event Handle to event. This could be INVALID_HANDLE if every plugin hooking |
|
ds@576
|
50 |
* this event has set the hook mode EventHookMode_PostNoCopy. |
|
ds@576
|
51 |
* @param name String containing the name of the event. |
|
ds@576
|
52 |
* @param dontBroadcast True if event was not broadcast to clients, false otherwise. |
|
ds@576
|
53 |
* @noreturn |
|
ds@576
|
54 |
*/ |
|
ds@576
|
55 |
public(Handle:event, const String:name[], bool:dontBroadcast), |
|
ds@576
|
56 |
}; |
|
ds@576
|
57 |
|
|
ds@576
|
58 |
/** |
|
ds@576
|
59 |
* Creates a hook for when a game event is fired. |
|
ds@576
|
60 |
* |
|
ds@576
|
61 |
* @param name Name of event. |
|
ds@576
|
62 |
* @param callback An EventHook function pointer. |
|
ds@576
|
63 |
* @param mode Optional EventHookMode determining the type of hook. |
|
ds@576
|
64 |
* @noreturn |
|
ds@576
|
65 |
* @error Invalid event name or invalid callback function. |
|
ds@576
|
66 |
*/ |
|
ds@576
|
67 |
native HookEvent(const String:name[], EventHook:callback, EventHookMode:mode=EventHookMode_Post); |
|
ds@576
|
68 |
|
|
ds@576
|
69 |
/** |
|
ds@576
|
70 |
* Removes a hook for when a game event is fired. |
|
ds@576
|
71 |
* |
|
ds@576
|
72 |
* @param name Name of event. |
|
ds@576
|
73 |
* @param callback An EventHook function pointer. |
|
ds@576
|
74 |
* @param mode Optional EventHookMode determining the type of hook. |
|
ds@576
|
75 |
* @noreturn |
|
ds@576
|
76 |
* @error Invalid callback function or no active hook for specified event. |
|
ds@576
|
77 |
*/ |
|
ds@576
|
78 |
native UnhookEvent(const String:name[], EventHook:callback, EventHookMode:mode=EventHookMode_Post); |
|
ds@576
|
79 |
|
|
ds@576
|
80 |
/** |
|
ds@576
|
81 |
* Creates a game event to be fired later. |
|
ds@576
|
82 |
* |
|
ds@576
|
83 |
* @param name Name of event. |
|
ds@576
|
84 |
* @return Handle to event or INVALID_HANDLE if event doesn't exist. |
|
ds@576
|
85 |
*/ |
|
ds@576
|
86 |
native Handle:CreateEvent(const String:name[]); |
|
ds@576
|
87 |
|
|
ds@576
|
88 |
/** |
|
ds@576
|
89 |
* Fires a game event. |
|
ds@576
|
90 |
* |
|
ds@576
|
91 |
* @param event Handle to the event. |
|
ds@576
|
92 |
* @param dontBroadcast Optional boolean that determines if event should be broadcast to clients. |
|
ds@576
|
93 |
* @noreturn |
|
ds@576
|
94 |
* @error Invalid or corrupt Handle. |
|
ds@576
|
95 |
*/ |
|
ds@712
|
96 |
native FireEvent(Handle:event, bool:dontBroadcast=false); |
|
ds@576
|
97 |
|
|
ds@576
|
98 |
/** |
|
ds@576
|
99 |
* Cancels a previously created game event that has not been fired. |
|
ds@576
|
100 |
* |
|
ds@576
|
101 |
* @param event Handled to the event. |
|
ds@576
|
102 |
* @noreturn |
|
ds@576
|
103 |
* @error Invalid or corrupt Handle. |
|
ds@576
|
104 |
*/ |
|
ds@576
|
105 |
native CancelCreatedEvent(Handle:event); |
|
ds@576
|
106 |
|
|
ds@576
|
107 |
/** |
|
ds@576
|
108 |
* Returns the boolean value of a game event's key. |
|
ds@576
|
109 |
* |
|
ds@576
|
110 |
* @param event Handle to the event. |
|
ds@576
|
111 |
* @param key Name of event key. |
|
ds@576
|
112 |
* @return The boolean value of the specfied event key. |
|
ds@576
|
113 |
* @error Invalid or corrupt Handle. |
|
ds@576
|
114 |
*/ |
|
ds@576
|
115 |
native bool:GetEventBool(Handle:event, const String:key[]); |
|
ds@576
|
116 |
|
|
ds@576
|
117 |
/** |
|
ds@576
|
118 |
* Sets the boolean value of a game event's key. |
|
ds@576
|
119 |
* |
|
ds@576
|
120 |
* @param event Handle to the event. |
|
ds@576
|
121 |
* @param key Name of event key. |
|
ds@576
|
122 |
* @param value New boolean value. |
|
ds@576
|
123 |
* @noreturn |
|
ds@576
|
124 |
* @error Invalid or corrupt Handle. |
|
ds@576
|
125 |
*/ |
|
ds@576
|
126 |
native SetEventBool(Handle:event, const String:key[], bool:value); |
|
ds@576
|
127 |
|
|
ds@576
|
128 |
/** |
|
ds@576
|
129 |
* Returns the integer value of a game event's key. |
|
ds@576
|
130 |
* |
|
ds@576
|
131 |
* @param event Handle to the event. |
|
ds@576
|
132 |
* @param key Name of event key. |
|
ds@576
|
133 |
* @return The integer value of the specfied event key. |
|
ds@576
|
134 |
* @error Invalid or corrupt Handle. |
|
ds@576
|
135 |
*/ |
|
ds@576
|
136 |
native GetEventInt(Handle:event, const String:key[]); |
|
ds@576
|
137 |
|
|
ds@576
|
138 |
/** |
|
ds@576
|
139 |
* Sets the integer value of a game event's key. |
|
ds@576
|
140 |
* |
|
ds@576
|
141 |
* @param event Handle to the event. |
|
ds@576
|
142 |
* @param key Name of event key. |
|
ds@576
|
143 |
* @param value New integer value. |
|
ds@576
|
144 |
* @noreturn |
|
ds@576
|
145 |
* @error Invalid or corrupt Handle. |
|
ds@576
|
146 |
*/ |
|
ds@576
|
147 |
native SetEventInt(Handle:event, const String:key[], value); |
|
ds@576
|
148 |
|
|
ds@576
|
149 |
/** |
|
ds@576
|
150 |
* Returns the floating point value of a game event's key. |
|
ds@576
|
151 |
* |
|
ds@576
|
152 |
* @param event Handle to the event. |
|
ds@576
|
153 |
* @param key Name of event key. |
|
ds@576
|
154 |
* @return The floating point value of the specfied event key. |
|
ds@576
|
155 |
* @error Invalid or corrupt Handle. |
|
ds@576
|
156 |
*/ |
|
ds@576
|
157 |
native Float:GetEventFloat(Handle:event, const String:key[]); |
|
ds@576
|
158 |
|
|
ds@576
|
159 |
/** |
|
ds@576
|
160 |
* Sets the floating point value of a game event's key. |
|
ds@576
|
161 |
* |
|
ds@576
|
162 |
* @param event Handle to the event. |
|
ds@576
|
163 |
* @param key Name of event key. |
|
ds@576
|
164 |
* @param value New floating point value. |
|
ds@576
|
165 |
* @noreturn |
|
ds@576
|
166 |
* @error Invalid or corrupt Handle. |
|
ds@576
|
167 |
*/ |
|
ds@576
|
168 |
native SetEventFloat(Handle:event, const String:key[], Float:value); |
|
ds@576
|
169 |
|
|
ds@576
|
170 |
/** |
|
ds@576
|
171 |
* Retrieves the string value of a game event's key. |
|
ds@576
|
172 |
* |
|
ds@576
|
173 |
* @param event Handle to the event. |
|
ds@576
|
174 |
* @param key Name of event key. |
|
ds@576
|
175 |
* @param value Buffer to store the value of the specified event key. |
|
ds@576
|
176 |
* @param maxlength Maximum length of string buffer. |
|
ds@576
|
177 |
* @noreturn |
|
ds@576
|
178 |
* @error Invalid or corrupt Handle. |
|
ds@576
|
179 |
*/ |
|
ds@576
|
180 |
native GetEventString(Handle:event, const String:key[], String:value[], maxlength); |
|
ds@576
|
181 |
|
|
ds@576
|
182 |
/** |
|
ds@576
|
183 |
* Sets the string value of a game event's key. |
|
ds@576
|
184 |
* |
|
ds@576
|
185 |
* @param event Handle to the event. |
|
ds@576
|
186 |
* @param key Name of event key. |
|
ds@576
|
187 |
* @param value New string value. |
|
ds@576
|
188 |
* @noreturn |
|
ds@576
|
189 |
* @error Invalid or corrupt Handle. |
|
ds@576
|
190 |
*/ |
|
ds@576
|
191 |
native SetEventString(Handle:event, const String:key[], const String:value[]); |
|
ds@576
|
192 |
|
|
ds@576
|
193 |
/** |
|
ds@576
|
194 |
* Retrieves the name of a game event. |
|
ds@576
|
195 |
* |
|
ds@576
|
196 |
* @param event Handle to the event. |
|
ds@576
|
197 |
* @param value Buffer to store the name of the event. |
|
ds@576
|
198 |
* @param maxlength Maximum length of string buffer. |
|
ds@576
|
199 |
* @noreturn |
|
ds@576
|
200 |
* @error Invalid or corrupt Handle. |
|
ds@576
|
201 |
*/ |
|
ds@576
|
202 |
native GetEventName(Handle:event, String:name[], maxlength); |