This extension catches whenever clients connect/disconnect and it adds sourcehooks on them so all of the game clients are already prehooked for developers and it also you give the ability to hook other game entities other than clients.
This extension is required by several sourcemod plugins. So you must install it before installing the plugin.
Requirements :
Plugin Developers Section :
Credits :
This extension is required by several sourcemod plugins. So you must install it before installing the plugin.
Requirements :
- Sourcemod v1.8 or Higher
- Download Hooker.zip file from this post.
- Extract the contents of zip file and put it into cstrike/addons/sourcemod folder of your server.
- Restart the server or change the map or use
sm exts load hooker
.
Plugin Developers Section :
C++:
/**
* Adds a Hook to a function
*
* @param type type of hook.
* @param func function name to send the hook to.
* @param post post hook or pre hook, pre=false and post=true.
* @noreturn
*/
native RegisterHook(HookType:type, Hooks:func, bool:post=false);
/**
* Adds hooks to the entity, then hooks will be retrieved using RegisterHook.
* @param type type of entity
* @param EntityIndex Entity index.
* @noreturn
* @error if entity is invalid or entity has been just created but has no propterties.
*/
native HookEntity(HK_Ents:type, EntityIndex);
/**
* Removes players hook.
*
* @param EntityIndex Entity index.
* @noreturn
*/
native UnHookPlayer(HK_Ents:type, PlayerIndex);
/**
* Forward called when an entity is created.
* @param EntIndex index of the entity that just got created.
* @param Classname classname of the entity that got created.
*/
forward HookerOnEntityCreated(EntIndex, const String:Classname[]);
HK_GameNameDescription
HK_WeaponDrop
HK_WeaponCanUse
HK_WeaponCanSwitchTo
HK_OnChangeActiveWeapon
HK_Touch
HK_StartTouch
HK_EndTouch
HK_EventKilled
HK_OnTakeDamage
HK_TraceAttack
HK_Spawn
HK_EntityThink
HK_ClientPreThink
HK_ClientPostThink
HK_PlayerJump
HK_PlayerDuck
HK_CommitSuicide
HK_Respawn
HK_SetModel
HK_ShowViewPortPanel
HK_ImpulseCommands
HK_WeaponDrop
HK_WeaponCanUse
HK_WeaponCanSwitchTo
HK_OnChangeActiveWeapon
HK_Touch
HK_StartTouch
HK_EndTouch
HK_EventKilled
HK_OnTakeDamage
HK_TraceAttack
HK_Spawn
HK_EntityThink
HK_ClientPreThink
HK_ClientPostThink
HK_PlayerJump
HK_PlayerDuck
HK_CommitSuicide
HK_Respawn
HK_SetModel
HK_ShowViewPortPanel
HK_ImpulseCommands
Entity types that should be used with HookEntity and UnHookPlayer
HKE_CBaseEntity
HKE_CCSPlayer
HKE_CTFPlayer
HKE_CDODPlayer
HKE_CHL2MP_Player
HKE_CINSPlayer
HKE_CBaseEntity
HKE_CCSPlayer
HKE_CTFPlayer
HKE_CDODPlayer
HKE_CHL2MP_Player
HKE_CINSPlayer
C++:
#pragma semicolon 1
#include <sourcemod>
#include <hooker>
public Plugin:myinfo =
{
name = "Changing Damage",
author = "Fredd",
description = "<- Description ->",
version = "",
url = "http://sourcemod.net/"
}
public OnPluginStart()
{
RegisterHook(HK_OnTakeDamage, TakeDamageFunction, false);
}
public OnClientPutInServer(client)
{
HookEntity(HKE_CCSPlayer, client);
}
public OnClientDisconnect(client)
{
UnHookPlayer(HKE_CCSPlayer, client);
}
public Action:TakeDamageFunction(client, &inflictor, &attacker, &Float:Damage, &DamageType, &AmmoType)
{
Damage += 10; //adds 10 to the damage
return Plugin_Changed; // tells the extension something was changed use the new value!
}
C++:
#pragma semicolon 1
#include <sourcemod>
#include <hooker>
public Plugin:myinfo =
{
name = "Using HookEntity on non players..",
author = "Fredd",
description = "<- Description ->",
version = "",
url = "http://sourcemod.net/"
}
public HookerOnEntityCreated(index, const String:Classname[])
{
if(strcmp(Classname, "prop_physics_multiplayer") == 0)
HookEntity(HKE_CBaseEntity, index);
}
public OnPluginStart()
{
RegisterHook(HK_Spawn, OnSpawnFunction, false);
}
public Action:OnSpawnFunction(entity)
{
//now this function will get called ONLY when a "prop_physics_multiplayer" spawns
// if a players were hooked this function will get calle don both players and "prop_physics_multiplayer" ents..
}
Credits :
- Fredd