Maybe something like this if the sound hook isn't a reliable method.
PHP Code:
#include <sourcemod>
#include <sdktools>
new g_offsNextSecondaryAttack, g_offsTimeWeaponIdle;
public OnPluginStart()
{
g_offsNextSecondaryAttack = FindSendPropOffs("CBaseCombatWeapon", "m_flNextSecondaryAttack");
g_offsTimeWeaponIdle = FindSendPropOffs("CBaseCombatWeapon", "m_flTimeWeaponIdle");
}
public Action:OnPlayerRunCmd(client, &buttons)
{
if(IsValidClient(client))
{
new weapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
if (weapon != -1)
{
new knife_weapon = GetPlayerWeaponSlot(client, 2);
if(knife_weapon != -1)
{
if(knife_weapon == weapon &&
buttons & IN_ATTACK2
&& GetEntDataFloat(weapon, g_offsNextSecondaryAttack) <= GetGameTime()
)//&& GetEntDataFloat(weapon, g_offsTimeWeaponIdle) >= GetGameTime())
{
PrintToChat(client, "Second Attack %f %f", GetEntDataFloat(weapon, g_offsNextSecondaryAttack), GetEntDataFloat(weapon, g_offsTimeWeaponIdle));
}
}
}
}
return Plugin_Continue;
}
bool IsValidClient(int client)
{
if (!(1 <= client <= MaxClients) || !IsClientInGame(client) || IsClientSourceTV(client) || IsClientReplay(client))
return false;
return true;
}
Note: I'm not sure what m_flTimeWeaponIdle exactly for as it doesn't seem to behave as i originally assumed.
You have to account for weapon draw time and primary attack cool down times as well but this should get you in the right direction.
__________________