|
DJ Post Spammer
Join Date: Feb 2008
Location: Netherlands
|

10-18-2009
, 11:15
[EXTENSION] SDK Hooks 1.3 (Updated 2010-05-12)
|
#1
|
So here we are again  Hacks, Hooker and DukeHacks are getting a bit outdated, and I didn't like how they were written, so I wrote this extension to combine the three of them, and to add some more goodies. Currently it supports CS:S, DOD:S, HL2DM, INS, L4D & TF2. Support for more mods can easily be added through the gamedata file, no editing of the extension required. Thanks to CrimsonGT for helping out with the CTakeDamageInfo hack, and pRED* for general C++ questions
Hook Types:
PHP Code:
enum SDKHookType { SDKHook_EndTouch, SDKHook_FireBulletsPost, SDKHook_OnTakeDamage, SDKHook_OnTakeDamagePost, SDKHook_PreThink, SDKHook_PostThink, SDKHook_SetTransmit, SDKHook_Spawn, SDKHook_StartTouch, SDKHook_Think, SDKHook_Touch, SDKHook_TraceAttack, SDKHook_TraceAttackPost, SDKHook_WeaponCanSwitchTo, SDKHook_WeaponCanUse, SDKHook_WeaponDrop, SDKHook_WeaponEquip, SDKHook_WeaponSwitch }
Hook Callbacks:
PHP Code:
funcenum SDKHookCB { // PreThink // PostThink public(client), // Spawn // Think public(entity), // EndTouch // StartTouch // Touch public(entity, other), // SetTransmit Action:public(entity, client), // WeaponCanSwitchTo // WeaponCanUse // WeaponDrop // WeaponEquip // WeaponSwitch Action:public(client, weapon), // OnTakeDamage Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype), // OnTakeDamagePost public(victim, attacker, inflictor, Float:damage, damagetype), // FireBullets public(client, shots, String:weaponname[]), // TraceAttack Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup), // TraceAttackPost public(victim, attacker, inflictor, Float:damage, damagetype, ammotype, hitbox, hitgroup) }
Forwards:
PHP Code:
/** * @brief When an entity is created * * @param entity Entity index * @param classname Class name * @noreturn */ forward OnEntityCreated(entity, const String:classname[]);
/** * @brief When an entity is destroyed * * @param entity Entity index * @noreturn */ forward OnEntityDestroyed(entity);
/** * @brief When the game description is retrieved * * @param gameDesc Game description * @noreturn */ forward Action:OnGetGameDescription(String:gameDesc[64]);
/** * @brief When the level is initialized * * @param mapName Name of the map * @param mapEntities Entities of the map * @noreturn */ forward Action:OnLevelInit(const String:mapName[], String:mapEntities[2097152]);
Natives:
PHP Code:
/** * @brief Hooks an entity * * @param entity Entity index * @param type Type of function to hook * @param callback Function to call when hook is called * @noreturn */ native SDKHook(entity, SDKHookType:type, SDKHookCB:callback);
/** * @brief Unhooks an entity * * @param entity Entity index * @param type Type of function to unhook * @param callback Callback function to unhook * @noreturn */ native SDKUnhook(entity, SDKHookType:type, SDKHookCB:callback);
Changelog
- 1.3 (credits to psychonic)
- Added four new requested hooktypes (PreThinkPost, PostThinkPost, ThinkPost, and ShouldCollide).
- Fixed issue with sdk functions being hooked multiple times when multiple hooks of the same type are made (thanks to Sammy Rock! for catching that).
- SDK Hooks will no longer load without having both the EntityFactoryDictionary signature and UpdateOnRemove offset present in sdkhooks.games.txt.
- SDKHook native now errors when using a hooktype not supported (not in gamedata) for current mod.
- Added new SDKHookEx native that does not error on unsuccessful hook but returns a success bool.
- Fixed WeaponCanSwitchTo calling the WeaponCanUse forward (thanks to Greyscale for catching that).
- Added debug server command "sdkhooks_listhooks" to list all current hooks.
- Updated gamedata to add ShouldCollide for all supported games.
- Updated gamedata to remove OnTakeDamage for L4D(2) as it does not function properly.
- 1.2 (credits to psychonic)
- Added two new hook types:
- SDKHook_WeaponCanSwitchTo
- SDKHook_WeaponCanUse
- Added some error checking on entity index values passed from plugins.
- Fixed clients not being unhooked when disconnecting.
- Fixed hooks from a plugin not being removed when plugin unloads.
- Fixed null pointer being passed in some cases on SDKHook_FireBulletsPost.
- Fixed some minor inconsistencies between include and extension.
- Fixed Makefile causing linux version to require GLIBC 2.4 (rhelgeby).
- 1.1 (credits to psychonic)
- Added OnGetGameDescription forward
- Added FireBullets, OnTakeDamagePost, TraceAttack & TraceAttackPost hooks
- Added support for Empires Mod, Fortress Forever, The Hidden: Source, Stargate: The Last Stand, Zombie Master & Zombie Panic: Source
- 1.0
Downloads
http://downloads.tsunami-productions.nl
__________________
My Plugins
Don't PM me asking for support, post in the plugin's topic.
Last edited by psychonic; 05-12-2010 at 12:22.
Reason: enabled syntax highlighting on the code blocks :3
|
|