Something like this should work to force a player to secondary attack with the knife:
PHP Code:
public OnClientPutInServer(client)
{
SDKHook(client, SDKHook_PostThinkPost, OnPostThinkPost);
}
public OnPostThinkPost(client)
{
new knife = GetPlayerWeaponSlot(client, CS_SLOT_KNIFE);
if(IsValidEntity(knife))
SetEntPropFloat(knife, Prop_Send, "m_flNextPrimaryAttack", (GetGameTime() + 9999.9));
}
Seeing if the player is using secondary attack with a knife on a damage hook can be done by checking the damage amount.
PHP Code:
public OnClientPutInServer(client)
{
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}
public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
{
if(!IsValidClient(attacker))
return Plugin_Continue;
if (damage > 55.0)
{
new weaponEnt = GetEntDataEnt2(attacker, activeOffset);
if(IsValidEdict(weaponEnt) && IsValidEntity(weaponEnt))
{
decl String:className[128];
GetEntityClassname(weaponEnt, className, sizeof(className));
if(StrEqual("weapon_knife", className))
{
//secondary attack with knife used
return Plugin_Changed;
}
}
}
return Plugin_Continue;
}
__________________