Examples
Adding a simple spawn hook:
Code:
public OnEntityCreated(entity, const String:classname[])
{
SDKHook(entity, SDKHook_Spawn, OnEntitySpawned);
}
public OnEntitySpawned(entity)
{
// Stuff here
}
Blocking switching to a specific weapon:
Code:
public OnClientPutInServer(client)
{
SDKHook(client, SDKHook_WeaponSwitch, OnWeaponSwitch);
}
public Action:OnWeaponSwitch(client, weapon)
{
decl String:sWeapon[32];
GetEdictClassname(weapon, sWeapon, sizeof(sWeapon));
if(StrEqual(sWeapon, "tf_weapon_rocketlauncher"))
return Plugin_Handled;
return Plugin_Continue;
}
Changing damage done by a specific weapon:
Code:
public OnClientPutInServer(client)
{
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}
public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
{
decl String:sWeapon[32];
GetEdictClassname(inflictor, sWeapon, sizeof(sWeapon));
if(StrEqual(sWeapon, "tf_weapon_flamethrower"))
{
damage *= 2.0;
return Plugin_Changed;
}
return Plugin_Continue;
}
Note, you don't have to worry about unhooking every hook before the entity is destroyed, or before your plugin is unloaded, the extension automatically does that for you.
__________________