Make SQL_LastInsertId and SQL_GetAffectedRows work on query handles, allowing their use with threaded queries
3 * =============================================================================
4 * SourceMod (C)2004-2011 AlliedModders LLC. All rights reserved.
5 * =============================================================================
7 * This file is part of the SourceMod/SourcePawn SDK.
9 * This program is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License, version 3.0, as published by the
11 * Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18 * You should have received a copy of the GNU General Public License along with
19 * this program. If not, see <http://www.gnu.org/licenses/>.
21 * As a special exception, AlliedModders LLC gives you permission to link the
22 * code of this program (as well as its derivative works) to "Half-Life 2," the
23 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 * by the Valve Corporation. You must obey the GNU General Public License in
25 * all respects for all other code used. Additionally, AlliedModders LLC grants
26 * this exception to all derivative works. AlliedModders LLC defines further
27 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 * or <http://www.sourcemod.net/license.php>.
33 #if defined _clientprefs_included
36 #define _clientprefs_included
39 * Cookie access types for client viewing
43 CookieAccess_Public, /**< Visible and Changeable by users */
44 CookieAccess_Protected, /**< Read only to users */
45 CookieAccess_Private, /**< Completely hidden cookie */
49 * Cookie Prefab menu types
53 CookieMenu_YesNo, /**< Yes/No menu with "yes"/"no" results saved into the cookie */
54 CookieMenu_YesNo_Int, /**< Yes/No menu with 1/0 saved into the cookie */
55 CookieMenu_OnOff, /**< On/Off menu with "on"/"off" results saved into the cookie */
56 CookieMenu_OnOff_Int, /**< On/Off menu with 1/0 saved into the cookie */
62 * An option is being drawn for a menu.
64 * INPUT : Client index and data if available.
65 * OUTPUT: Buffer for rendering, maxlength of buffer.
67 CookieMenuAction_DisplayOption = 0,
70 * A menu option has been selected.
72 * INPUT : Client index and any data if available.
74 CookieMenuAction_SelectOption = 1,
80 * A successful return value/result on any client prefs native only guarantees that the local cache has been updated.
81 * Database connection problems can still prevent the data from being permanently saved. Connection problems will be logged as
82 * errors by the clientprefs extension.
86 * Creates a new Client preference cookie.
88 * Handles returned by RegClientCookie can be closed via CloseHandle() when
91 * @param name Name of the new preference cookie.
92 * @param description Optional description of the preference cookie.
93 * @param access What CookieAccess level to assign to this cookie.
94 * @return A handle to the newly created cookie. If the cookie already
95 * exists, a handle to it will still be returned.
96 * @error Cookie name is blank.
98 native Handle:RegClientCookie(const String:name[], const String:description[], CookieAccess:access);
101 * Searches for a Client preference cookie.
103 * Handles returned by FindClientCookie can be closed via CloseHandle() when
106 * @param name Name of cookie to find.
107 * @return A handle to the cookie if it is found. INVALID_HANDLE otherwise.
109 native Handle:FindClientCookie(const String:name[]);
112 * Set the value of a Client preference cookie.
114 * @param client Client index.
115 * @param cookie Client preference cookie handle.
116 * @param value String value to set.
118 * @error Invalid cookie handle or invalid client index.
120 native SetClientCookie(client, Handle:cookie, const String:value[]);
123 * Retrieve the value of a Client preference cookie.
125 * @param client Client index.
126 * @param cookie Client preference cookie handle.
127 * @param buffer Copyback buffer for value.
128 * @param maxlen Maximum length of the buffer.
130 * @error Invalid cookie handle or invalid client index.
132 native GetClientCookie(client, Handle:cookie, String:buffer[], maxlen);
135 * Checks if a clients cookies have been loaded from the database.
137 * @param client Client index.
138 * @return True if loaded, false otherwise.
139 * @error Invalid client index.
141 native bool:AreClientCookiesCached(client);
144 * Called once a client's saved cookies have been loaded from the database.
146 * @param client Client index.
148 forward OnClientCookiesCached(client);
151 * Cookie Menu Callback prototype
153 * @param client Client index.
154 * @param action CookeMenuAction being performed.
155 * @param data Info data passed.
156 * @param buffer Outbut buffer.
157 * @param maxlen Max length of the output buffer.
159 functag public CookieMenuHandler(client, CookieMenuAction:action, any:info, String:buffer[], maxlen);
162 * Add a new prefab item to the client cookie settings menu.
164 * Note: This handles everything automatically and does not require a callback
166 * @param cookie Client preference cookie handle.
167 * @param type A CookieMenu prefab menu type.
168 * @param display Text to show on the menu.
169 * @param handler Optional handler callback for translations and output on selection
170 * @param info Info data to pass to the callback.
172 * @error Invalid cookie handle.
174 native SetCookiePrefabMenu(Handle:cookie, CookieMenu:type, const String:display[], CookieMenuHandler:handler=CookieMenuHandler:-1, info=0);
177 * Adds a new item to the client cookie settings menu.
179 * Note: This only adds the top level menu item. You need to handle any submenus from the callback.
181 * @param handler A MenuHandler callback function.
182 * @param info Data to pass to the callback.
183 * @param display Text to show on the menu.
185 * @error Invalid cookie handle.
187 native SetCookieMenuItem(CookieMenuHandler:handler, any:info, const String:display[]);
190 * Displays the settings menu to a client.
192 * @param client Client index.
195 native ShowCookieMenu(client);
198 * Gets a cookie iterator. Must be freed with CloseHandle().
200 * @return A new cookie iterator.
202 native Handle:GetCookieIterator();
205 * Reads a cookie iterator, then advances to the next cookie if any.
207 * @param iter Cookie iterator Handle.
208 * @param name Name buffer.
209 * @param nameLen Name buffer size.
210 * @param access Access level of the cookie.
211 * @param desc Cookie description buffer.
212 * @param descLen Cookie description buffer size.
214 * @return True on success, false if there are no more commands.
216 native bool:ReadCookieIterator(Handle:iter,
219 &CookieAccess:access,
224 * Returns the access level of a cookie
226 * @param cookie Client preference cookie handle.
227 * @return CookieAccess access level.
228 * @error Invalid cookie handle.
230 native CookieAccess:GetCookieAccess(Handle:cookie);
233 * Returns the last updated timestamp for a client cookie
235 * @param client Client index.
236 * @param cookie Cookie handle.
237 * @return Last updated timestamp.
239 native GetClientCookieTime(client, Handle:cookie);
242 * Do not edit below this line!
244 public Extension:__ext_cprefs =
246 name = "Client Preferences",
247 file = "clientprefs.ext",
249 #if defined REQUIRE_EXTENSIONS
256 #if !defined REQUIRE_EXTENSIONS
257 public __ext_cprefs_SetNTVOptional()
259 MarkNativeAsOptional("RegClientCookie");
260 MarkNativeAsOptional("FindClientCookie");
261 MarkNativeAsOptional("SetClientCookie");
262 MarkNativeAsOptional("GetClientCookie");
263 MarkNativeAsOptional("AreClientCookiesCached");
264 MarkNativeAsOptional("SetCookiePrefabMenu");
265 MarkNativeAsOptional("SetCookieMenuItem");
266 MarkNativeAsOptional("ShowCookieMenu");
267 MarkNativeAsOptional("GetCookieIterator");
268 MarkNativeAsOptional("ReadCookieIterator");
269 MarkNativeAsOptional("GetCookieAccess");
270 MarkNativeAsOptional("GetClientCookieTime");