Untested
Edit: You will probably get no results with the previous code since the time value is float [25.31] and it is very unlikely that two numbers will ever be identical. I edited the code to allow you to specify if the knife attacks happened within g_fKnifeTime seconds from one another then it is considered the same time. Default is 1 second
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#define PLUGIN "Detect knife at same time"
#define VERSION "1.0"
#define AUTHOR "bugsy"
new Float: g_fKnifeAttacked[33];
new g_iMaxPlayers;
const Float: g_fKnifeTime = 1.0;
#define IsPlayer(%1) ( 1 <= %1 <= g_iMaxPlayers )
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
RegisterHam( Ham_TakeDamage , "player" , "fw_HamTakeDamage" )
g_iMaxPlayers = get_maxplayers();
}
public fw_HamTakeDamage( iVictim , iInflictor , iAttacker , Float:fDamage , iBitDamage )
{
static i;
if ( IsPlayer( iAttacker ) && ( get_user_weapon( iAttacker ) == CSW_KNIFE ) )
{
g_fKnifeAttacked[ iVictim ] = get_gametime();
for ( i = 1 ; i <= g_iMaxPlayers ; i++ )
if ( ( i != iVictim ) && g_fKnifeAttacked[ i ] && ( floatabs( g_fKnifeAttacked[ i ] - g_fKnifeAttacked[ iVictim ] ) <= g_fKnifeTime ) )
client_print( iVictim , print_chat , "Knifed at same time as player id - %d" , i );
}
}
__________________