The weapon entity is passed to the ham forward, not player id. Use pev( iEntity , pev_owner ) to get the player id. You will still get the knife attack animation though no attack is actually occurring.
Untested
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
new g_iMaxPlayers;
#define IsPlayer(%1) (1<=%1<=g_iMaxPlayers)
public plugin_init()
{
RegisterHam( Ham_Weapon_PrimaryAttack , "weapon_knife" , "BlockKnife" );
RegisterHam( Ham_Weapon_SecondaryAttack , "weapon_knife" , "BlockKnife" );
g_iMaxPlayers = get_maxplayers();
}
public BlockKnife( iEntity )
{
new iEnemy , iBody , iPlayer = pev( iEntity , pev_owner );
if ( !IsPlayer( iPlayer ) )
return HAM_IGNORED;
get_user_aiming( iPlayer , iEnemy , iBody );
return IsPlayer( iEnemy ) ? HAM_IGNORED : HAM_SUPERCEDE;
}
__________________