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

10-18-2009
, 12:15
SDK Hooks 2.1 - Updated 2011-9-10
|
#1
|
SDK Hooks is now included with SourceMod 1.5. Previous versions are unsupported.
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 almost every game and mod that SourceMod itself does. 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:
Code:
SDKHook_EndTouch
SDKHook_EndTouchPost
SDKHook_FireBulletsPost
SDKHook_GroundEntChangedPost
SDKHook_OnTakeDamage
SDKHook_OnTakeDamagePost
SDKHook_PreThink
SDKHook_PreThinkPost
SDKHook_PostThink
SDKHook_PostThinkPost
SDKHook_Reload
SDKHook_ReloadPost
SDKHook_SetTransmit
SDKHook_ShouldCollide
SDKHook_Spawn
SDKHook_SpawnPost
SDKHook_StartTouch
SDKHook_StartTouchPost
SDKHook_Think
SDKHook_ThinkPost
SDKHook_Touch
SDKHook_TouchPost
SDKHook_TraceAttack
SDKHook_TraceAttackPost
SDKHook_Use
SDKHook_UsePost
SDKHook_VPhysicsUpdate
SDKHook_VPhysicsUpdatePost
SDKHook_WeaponCanSwitchTo
SDKHook_WeaponCanSwitchToPost
SDKHook_WeaponCanUse
SDKHook_WeaponCanUsePost
SDKHook_WeaponDrop
SDKHook_WeaponDropPost
Hook Callbacks:
< see sdkhooks.inc >
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 Hooks an entity
*
* @param entity Entity index
* @param type Type of function to hook
* @param callback Function to call when hook is called
* @return bool Hook Successful
*/
native bool:SDKHookEx(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);
/**
* @brief Applies damage to an entity
*
* @note Force application is dependent on game and damage type(s)
*
* @param entity Entity index taking damage
* @param inflictor Inflictor entity index
* @param attacker Attacker entity index
* @param damage Amount of damage
* @param damageType Bitfield of damage types
* @param weapon Weapon index (orangebox and later) or -1 for unspecified
* @param damageForce Velocity of damage force
* @param damagePosition Origin of damage
* @noreturn
*/
native SDKHooks_TakeDamage(entity, inflictor, attacker, Float:damage, damageType=DMG_GENERIC, weapon=-1, const Float:damageForce[3]=NULL_VECTOR, const Float:damagePosition[3]=NULL_VECTOR);
/**
* @brief Forces a client to drop the specified weapon
*
* @param client Client index.
* @param weapon Weapon entity index.
* @param vecTarget Location to toss weapon to, or NULL_VECTOR for default.
* @param vecVelocity Velocity at which to toss weapon, or NULL_VECTOR for default.
* @noreturn
* @error Invalid client or weapon entity, weapon not owned by client.
*/
native SDKHooks_DropWeapon(client, weapon, const Float:vecTarget[3]=NULL_VECTOR, const Float:vecVelocity[3]=NULL_VECTOR);
Changelog
- 2.1 (psychonic)
- Updated gamedata for many games.
- Added gamedata for Nuclear Dawn, Age of Chivalry, and CSPromod by request.
- Fixed a case where extremely invalid entity indexes were passed through to to some callbacks (notably WeaponDrop) rather than -1 for invalid.
- Fixed a case where 4095 was being passed for invalid ent indexes rather than -1.
- Added more safety checks when hooking to guard against hooking functions that don't exist on type of given entity. Will now error instead of crash.
- Initial game description now gets populated properly before being passed to OnGetGameDescription forward.
- Added Reload and ReloadPost hooks by request. Note that you should be hooking the weapon rather than the player.
- SDKHook_Spawn is now blockable by returning Plugin_Handled.
- Added "damagecustom" value to ontakedamage hooks. To check for support of this at runtime, check the status of the "SDKHook_DmgCustomInOTD" feature.
- Fixed player penetration count sometimes getting set to random values in TF2 when using SDKHooks_TakeDamage native.
- 2.0 (psychonic)
- Fixed loading issue on EP2V after 2011-04-14 update.
- Updated lots of gamedata.
- Added support for Alien Swarm, Dino D-Day, Dark Messiah, and Bloody Good Time.
- Added the much-requested 'TakeDamage' native that DukeHacks had.
- Added SDKHooks_DropWeapon native.
- Added many new posthook types for existing hook types.
- Added VPhysicsThink, GroundEntChanged, and Use hooks.
- Passing and allowing changes to the damage force and position OnTakeDamage are now enabled (think: removing knockback).
- Touch hooks are now blockable.
- Made (breaking) changes to ShouldCollide hook to make it behave as expected.
- SDKHooks now registers a library, "sdkhooks", for use with LibraryExists, OnLibraryAdded, and OnLibraryRemoved natives in SM.
- Much code cleanup, mostly by Tsunami
- Distribution simplified. (single package with files for all platforms)
- 1.3 (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 (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 (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 (Tsunami)
Upgrading from 1.x.x to 2.0.0:
For users, - Your existing plugins that use SDKHooks should continue to work fine (with the exception of ones that use the ShouldCollide hook)
- Before upgrading, stop your gameserver and delete the following files if they exist or SDKHooks 2.x.x will not load.
- gamedata/sdkhooks.games.txt
- extensions/sdkhooks.ext.dll
- extensions/sdkhooks.ext.so
For developers, - Any plugins that use the ShouldCollide hook will need to be updated and recompiled with the new callback prototype.
- If you take advantage of any features new to SDKHooks 2.0, your plugin will need a recompile (obviously) and SDKHooks 2.0 will be required. Else, it should still load on 1.x.
- The new, preferred method to detect the optional existance of SDKHooks is checking for the "sdkhooks" library rather than getting the extension status. This will guarantee that it is 2.0 or higher and is loaded.
__________________
Last edited by DJ Tsunami; 09-22-2013 at 12:05.
|
|