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_included
19 #define _sdktools_included
22 #include <sdktools_functions>
23 #include <sdktools_tempents>
24 #include <sdktools_tempents_stocks>
25 #if !defined SDKTOOLS_DISABLE_SOUNDAPI
26 #include <sdktools_sound>
31 SDKCall_Static, /**< Static call */
32 SDKCall_Entity, /**< CBaseEntity call */
33 SDKCall_Player, /**< CBasePlayer call */
38 SDKLibrary_Server, /**< server.dll/server_i486.so */
39 SDKLibrary_Engine, /**< engine.dll/engine_*.so */
42 enum SDKFuncConfSource
44 SDKConf_Virtual = 0, /**< Read a virtual index from the Offsets section */
45 SDKConf_Signature = 1, /**< Read a signature from the Signatures section */
50 SDKType_CBaseEntity, /**< CBaseEntity (always as pointer) */
51 SDKType_CBasePlayer, /**< CBasePlayer (always as pointer) */
52 SDKType_Vector, /**< Vector (pointer, byval, or byref) */
53 SDKType_QAngle, /**< QAngles (pointer, byval, or byref) */
54 SDKType_PlainOldData, /**< Integer/generic data <=32bit (any) */
55 SDKType_Float, /**< Float (any) */
56 SDKType_Edict, /**< edict_t (always as pointer) */
57 SDKType_String, /**< NULL-terminated string (always as pointer) */
58 SDKType_Bool, /**< Boolean (any) */
63 SDKPass_Pointer, /**< Pass as a pointer */
64 SDKPass_Plain, /**< Pass as plain data */
65 SDKPass_ByValue, /**< Pass an object by value */
66 SDKPass_ByRef, /**< Pass an object by reference */
69 #define VDECODE_FLAG_ALLOWNULL (1<<0) /**< Allow NULL for pointers */
70 #define VDECODE_FLAG_ALLOWNOTINGAME (1<<1) /**< Allow players not in game */
71 #define VDECODE_FLAG_ALLOWWORLD (1<<2) /**< Allow World entity */
72 #define VDECODE_FLAG_BYREF (1<<3) /**< Floats/ints by reference */
74 #define VENCODE_FLAG_COPYBACK (1<<0) /**< Copy back data once done */
77 * Starts the preparation of an SDK call.
79 * @param type Type of function call this will be.
82 native StartPrepSDKCall(SDKCallType:type);
85 * Sets the virtual index of the SDK call if it is virtual.
87 * @param vtblidx Virtual table index.
90 native PrepSDKCall_SetVirtual(vtblidx);
93 * Finds an address in a library and sets it as the address to use for the SDK call.
95 * @param lib Library to use.
96 * @param signature Binary data to search for in the library. If it starts with '@',
97 * the bytes parameter is ignored and the signature is interpreted
98 * as a symbol lookup in the library.
99 * @param bytes Number of bytes in the binary search string.
100 * @return True on success, false if nothing was found.
102 native bool:PrepSDKCall_SetSignature(SDKLibrary:lib, const String:signature[], bytes);
105 * Finds an address or virtual function index in a GameConfig file and sets it as
106 * the calling information for the SDK call.
108 * @param gameconf GameConfig Handle, or INVALID_HANDLE to use sdktools.games.txt.
109 * @param source Whether to look in Offsets or Signatures.
110 * @param name Name of the property to find.
111 * @return True on success, false if nothing was found.
113 native bool:PrepSDKCall_SetFromConf(Handle:gameconf, SDKFuncConfSource:source, const String:name[]);
116 * Sets the return information of an SDK call. Do not call this if there is no return data.
117 * This must be called if there is a return value (i.e. it is not necessarily safe to ignore
120 * @param type Data type to convert to/from.
121 * @param pass How the data is passed in C++.
122 * @param decflags Flags on decoding from the plugin to C++.
123 * @param encflags Flags on encoding from C++ to the plugin.
126 native PrepSDKCall_SetReturnInfo(SDKType:type, SDKPassMethod:pass, decflags=0, encflags=0);
129 * Adds a parameter to the calling convention. This should be called in normal ascending order.
131 * @param type Data type to convert to/from.
132 * @param pass How the data is passed in C++.
133 * @param decflags Flags on decoding from the plugin to C++.
134 * @param encflags Flags on encoding from C++ to the plugin.
137 native PrepSDKCall_AddParameter(SDKType:type, SDKPassMethod:pass, decflags=0, encflags=0);
140 * Finalizes an SDK call preparation and returns the resultant Handle.
142 * @return A new SDKCall Handle on success, or INVALID_HANDLE on failure.
144 native Handle:EndPrepSDKCall();
147 * Calls an SDK function with the given parameters.
149 * If the call type is Entity or Player, the index MUST ALWAYS be the FIRST parameter passed.
150 * If the return value is a Vector or QAngles, the SECOND parameter must be a Float[3].
151 * If the return value is a string, the THIRD parameter must be a String buffer, and the
152 * FOURTH parameter must be the maximum length.
153 * All parameters must be passed after the above is followed. Failure to follow these
154 * rules will result in crashes or wildly unexpected behavior!
156 * If the return value is a float or integer, the return value will be this value.
157 * If the return value is a CBaseEntity, CBasePlayer, or edict, the return value will
158 * always be the entity index, or -1 for NULL.
160 * @param call SDKCall Handle.
161 * @param ... Call Parameters.
162 * @return Simple return value, if any.
163 * @error Invalid Handle or internal decoding error.
165 native any:SDKCall(Handle:call, any:...);
169 * Do not edit below this line!
171 public Extension:__ext_sdktools =
174 file = "sdktools.ext",
175 #if defined AUTOLOAD_EXTENSIONS
180 #if defined REQUIRE_EXTENSIONS