reapi.inc
Original include source with line numbers.
| 1 | #if defined _reapi_included |
| 2 | #endinput |
| 3 | #endif |
| 4 | |
| 5 | #define _reapi_included |
| 6 | |
| 7 | #if AMXX_VERSION_NUM >= 175 |
| 8 | #pragma reqlib reapi |
| 9 | #if !defined AMXMODX_NOAUTOLOAD |
| 10 | #pragma loadlib reapi |
| 11 | #endif |
| 12 | #else |
| 13 | #pragma library reapi |
| 14 | #endif |
| 15 | |
| 16 | enum hooks_tables_e |
| 17 | { |
| 18 | ht_engine, |
| 19 | ht_gamedll, |
| 20 | ht_animating, |
| 21 | ht_player, |
| 22 | ht_gamerules, |
| 23 | ht_rechecker, |
| 24 | ht_grenade, |
| 25 | ht_weaponbox, |
| 26 | ht_weapon, |
| 27 | ht_gib, |
| 28 | ht_cbaseentity, |
| 29 | ht_botmanager |
| 30 | }; |
| 31 | |
| 32 | enum members_tables_e |
| 33 | { |
| 34 | mt_gamerules, |
| 35 | mt_base, |
| 36 | mt_animating, |
| 37 | mt_basemonster, |
| 38 | mt_player, |
| 39 | mt_entvars, |
| 40 | mt_playermove, |
| 41 | mt_movevars, |
| 42 | mt_usercmd, |
| 43 | mt_pmtrace, |
| 44 | mt_csplayer, |
| 45 | mt_baseitem, |
| 46 | mt_baseweapon, |
| 47 | mt_weaponbox, |
| 48 | mt_armoury, |
| 49 | mt_grenade, |
| 50 | mt_p228, |
| 51 | mt_scout, |
| 52 | mt_hegrenade, |
| 53 | mt_xm1014, |
| 54 | mt_c4, |
| 55 | mt_mac10, |
| 56 | mt_aug, |
| 57 | mt_smokegrenade, |
| 58 | mt_elite, |
| 59 | mt_fiveseven, |
| 60 | mt_ump45, |
| 61 | mt_sg550, |
| 62 | mt_galil, |
| 63 | mt_famas, |
| 64 | mt_usp, |
| 65 | mt_glock18, |
| 66 | mt_awp, |
| 67 | mt_mp5n, |
| 68 | mt_m249, |
| 69 | mt_m3, |
| 70 | mt_m4a1, |
| 71 | mt_tmp, |
| 72 | mt_g3sg1, |
| 73 | mt_deagle, |
| 74 | mt_sg552, |
| 75 | mt_ak47, |
| 76 | mt_knife, |
| 77 | mt_p90, |
| 78 | mt_shield, |
| 79 | mt_rebuystruct, |
| 80 | mt_mapinfo, |
| 81 | mt_csplayerweapon, |
| 82 | mt_gib, |
| 83 | mt_netadr, |
| 84 | mt_csentity |
| 85 | }; |
| 86 | |
| 87 | #define ReAPIFunc {EngineFunc, GamedllFunc, GamedllFunc_CBaseAnimating, GamedllFunc_CBasePlayer, GamedllFunc_CSGameRules, GamedllFunc_CGrenade, GamedllFunc_CWeaponBox, ReCheckerFunc, GamedllFunc_CBasePlayerWeapon, GamedllFunc_CGib, GamedllFunc_CBaseEntity, GamedllFunc_CBotManager} |
| 88 | |
| 89 | // Is like FNullEnt |
| 90 | #define is_nullent(%0) (%0 == 0 || is_entity(%0) == false) |
| 91 | |
| 92 | #define MAX_REGION_RANGE 1024 |
| 93 | |
| 94 | #define BEGIN_FUNC_REGION(%0) (any:MAX_REGION_RANGE * hooks_tables_e:ht_%0) |
| 95 | #define BEGIN_MEMBER_REGION(%0) (any:MAX_REGION_RANGE * members_tables_e:mt_%0) |
| 96 | |
| 97 | #include <cssdk_const> |
| 98 | |
| 99 | #include <reapi_version> |
| 100 | #include <reapi_engine> // @note: only for ReHLDS |
| 101 | #include <reapi_gamedll> // @note: only for gamedll Counter-Strike (ReGameDLL_CS) |
| 102 | |
| 103 | // If you want to use s/get_member unsafe version, |
| 104 | // then macro MEMBER_UNSAFE must be defined before including header reapi.inc |
| 105 | #if !defined(MEMBER_UNSAFE) |
| 106 | #define set_member set_member_s |
| 107 | #define get_member get_member_s |
| 108 | #endif |
| 109 | |
| 110 | // addons |
| 111 | #include <reapi_vtc> |
| 112 | #include <reapi_reunion> |
| 113 | #include <reapi_rechecker> |
| 114 | |
| 115 | /** |
| 116 | * Hookchain return types |
| 117 | */ |
| 118 | enum |
| 119 | { |
| 120 | HC_CONTINUE = 0, // Plugin didn't take any action |
| 121 | HC_SUPERCEDE, // Skip real function, use my return value |
| 122 | HC_BREAK // Skip all forwards and real function, use my return value |
| 123 | // @note Warning: Be very careful, using this type of return will skip calls for all following AMXX plugins |
| 124 | }; |
| 125 | |
| 126 | /** |
| 127 | * Hookchain argument types |
| 128 | */ |
| 129 | enum AType |
| 130 | { |
| 131 | ATYPE_INTEGER = 0, |
| 132 | ATYPE_FLOAT, |
| 133 | ATYPE_STRING, |
| 134 | ATYPE_CLASSPTR, |
| 135 | ATYPE_EDICT, |
| 136 | ATYPE_EVARS, |
| 137 | ATYPE_BOOL, |
| 138 | ATYPE_VECTOR, |
| 139 | ATYPE_TRACE |
| 140 | }; |
| 141 | |
| 142 | enum HookChain |
| 143 | { |
| 144 | INVALID_HOOKCHAIN = 0 |
| 145 | }; |
| 146 | |
| 147 | /* |
| 148 | * Hook API function that are available into enum. |
| 149 | * Look at the enums for parameter lists. |
| 150 | * |
| 151 | * @param function The function to hook |
| 152 | * @param callback The forward to call |
| 153 | * @param post Whether or not to forward this in post |
| 154 | * |
| 155 | * @return Returns a hook handle. Use EnableHookChain/DisableHookChain to toggle the forward on or off |
| 156 | */ |
| 157 | native HookChain:RegisterHookChain(ReAPIFunc:function_id, const callback[], post = 0); |
| 158 | |
| 159 | /* |
| 160 | * Stops a hook from triggering. |
| 161 | * Use the return value from RegisterHookChain as the parameter here! |
| 162 | * |
| 163 | * @param hook The hook to stop |
| 164 | * |
| 165 | */ |
| 166 | native bool:DisableHookChain(HookChain:hook); |
| 167 | |
| 168 | /* |
| 169 | * Starts a hook back up. |
| 170 | * Use the return value from RegisterHookChain as the parameter here! |
| 171 | * |
| 172 | * @param hook The hook to re-enable |
| 173 | * |
| 174 | * @return Returns true if the function is successfully executed, otherwise false |
| 175 | */ |
| 176 | native bool:EnableHookChain(HookChain:hook); |
| 177 | |
| 178 | /* |
| 179 | * Sets the return value of a hookchain. |
| 180 | * |
| 181 | * @param type To specify the ATYPE_* parameter, look at the enum AType |
| 182 | * @param value The value to set the return to |
| 183 | * |
| 184 | */ |
| 185 | native SetHookChainReturn(AType:type, any:...); |
| 186 | |
| 187 | /* |
| 188 | * Gets the return value of the current hookchain. |
| 189 | * This has no effect in pre hookchain. |
| 190 | * |
| 191 | * @param type To specify the ATYPE_* parameter, look at the enum AType |
| 192 | * @param [maxlen] Max length of string (optional) |
| 193 | * |
| 194 | * @return If an integer or boolean or one byte or float, array or everything else is passed via 1st argument and more |
| 195 | */ |
| 196 | native any:GetHookChainReturn(AType:type, any:...); |
| 197 | |
| 198 | /* |
| 199 | * Set hookchain argument. |
| 200 | * This has no effect in post hookchain. |
| 201 | * |
| 202 | * @param number Number of argument |
| 203 | * @param value New value |
| 204 | * @param [maxlen] Max length of string (optional) |
| 205 | * |
| 206 | * @return Returns true if the function is successfully executed, otherwise false |
| 207 | */ |
| 208 | native SetHookChainArg(number, AType:type, any:...); |
| 209 | |
| 210 | /* |
| 211 | * Return call state of original API function (that are available into enum). |
| 212 | * Look at the enums for parameter lists. |
| 213 | * |
| 214 | * @param func The function to get state |
| 215 | * |
| 216 | * @return Returns true if the original function was called, otherwise false |
| 217 | */ |
| 218 | native bool:IsReapiHookOriginalWasCalled(ReAPIFunc:function_id); |
| 219 | |
| 220 | /* |
| 221 | * Returns the current hookchain handle. |
| 222 | * |
| 223 | * @return Returns the hook handle |
| 224 | */ |
| 225 | native HookChain:GetCurrentHookChainHandle(); |
| 226 | |
| 227 | /* |
| 228 | * Compares the entity to a specified classname. |
| 229 | * @note This native also checks the validity of an entity. |
| 230 | * |
| 231 | * @return true/false |
| 232 | */ |
| 233 | native bool:FClassnameIs(const entityIndex, const className[]); |
| 234 | |
| 235 | /* |
| 236 | * To get WeaponIdType from grenade entity |
| 237 | * |
| 238 | * @param entity Grenade entity |
| 239 | * |
| 240 | * @return return enum's of WeaponIdType |
| 241 | */ |
| 242 | native WeaponIdType:GetGrenadeType(const entityIndex); |
| 243 | |
| 244 | /* |
| 245 | * Sets the view entity on a client. |
| 246 | * This allows pfnSetView able to hooks. |
| 247 | * |
| 248 | * @param index Client index |
| 249 | * @param viewEntity Entity index |
| 250 | * |
| 251 | */ |
| 252 | native engset_view(const index, const viewEntity); |
| 253 | |
| 254 | /* |
| 255 | * Gets the return index of the current view entity on a client. |
| 256 | * |
| 257 | * @param index Client index |
| 258 | * |
| 259 | */ |
| 260 | native get_viewent(const index); |
| 261 | |
| 262 | /* |
| 263 | * Check if the entity is valid. |
| 264 | * |
| 265 | * @return true/false |
| 266 | */ |
| 267 | native bool:is_entity(const entityIndex); |
| 268 | |
| 269 | /* |
| 270 | * Check if ReHLDS is available. |
| 271 | * |
| 272 | * @return true/false |
| 273 | */ |
| 274 | native bool:is_rehlds(); |
| 275 | |
| 276 | /* |
| 277 | * Check if ReGameDLL is available. |
| 278 | * |
| 279 | * @return true/false |
| 280 | */ |
| 281 | native bool:is_regamedll(); |
| 282 | |
| 283 | /* |
| 284 | * Check if Reunion is available. |
| 285 | * |
| 286 | * @return true/false |
| 287 | * |
| 288 | */ |
| 289 | native bool:has_reunion(); |
| 290 | |
| 291 | /* |
| 292 | * Check if VTC is available. |
| 293 | * |
| 294 | * @return true/false |
| 295 | */ |
| 296 | native bool:has_vtc(); |
| 297 | |
| 298 | /* |
| 299 | * Check if Rechecker is available. |
| 300 | * |
| 301 | * @return true/false |
| 302 | */ |
| 303 | native bool:has_rechecker(); |
| 304 | |
| 305 | /* |
| 306 | * This is the callback from the module that gives major/minor versions for verifying compatibility for ReAPI versions. |
| 307 | * If an AMXX plugin gets a failure, then you do need to upgrade to the latest version of the ReAPI module or update the files included for AMXX plugins. |
| 308 | * Do not modify this! |
| 309 | */ |
| 310 | public __reapi_version_check(const majorVersion, const minorVersion) |
| 311 | { |
| 312 | if (majorVersion != REAPI_VERSION_MAJOR) |
| 313 | { |
| 314 | new temp[512]; |
| 315 | formatex(temp, sizeof temp - 1, "[ReAPI]: Api major version mismatch; expected %d, real %d", REAPI_VERSION_MAJOR, majorVersion); |
| 316 | set_fail_state(temp); |
| 317 | return; |
| 318 | } |
| 319 | |
| 320 | if (minorVersion < REAPI_VERSION_MINOR) |
| 321 | { |
| 322 | new temp[512]; |
| 323 | formatex(temp, sizeof temp - 1, "[ReAPI]: Api minor version mismatch; expected at least %d, real %d", REAPI_VERSION_MINOR, minorVersion); |
| 324 | set_fail_state(temp); |
| 325 | return; |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | // Always at the bottom of the reapi.inc file! |
| 330 | #include <reapi_stocks> // @note: additional stocks for ReAPI (Credits: Vaqtincha) |