Re: what best method detect double kill ?
If this is what you mean by double kill then this is what you want. This will detect if player has killed 2 or more players with one bullet.
PHP Code:
#include <amxmodx> #include <amxmisc> #include <engine> #include <hamsandwich> #include <fakemeta> #define VERSION "1.0" new g_iMaxPlayers #define FIRST_PLAYER_ID 1 #define IsPlayer(%1) ( FIRST_PLAYER_ID <= %1 <= g_iMaxPlayers ) #define GetBit(%1,%2) ( %1 & 1 << ( %2 & 31 ) ) #define SetBit(%1,%2) ( %1 |= ( 1 << ( %2 & 31 ) ) ) #define DelBit(%1,%2) ( %1 &= ~( 1 << ( %2 & 31 ) ) ) const MAX_PLAYERS = 32 new is_Alive, is_Connected, iKillerShot new g_iGunEvent_IDsBitsum, g_fwid new g_iShotKills[ MAX_PLAYERS + 1 ] //Cvar new g_pCvar_Enabled new const g_iGunEvents[][] = { "events/awp.sc", "events/g3sg1.sc", "events/ak47.sc", "events/scout.sc", "events/m249.sc", "events/m4a1.sc", "events/sg552.sc", "events/aug.sc", "events/sg550.sc", "events/m3.sc", "events/xm1014.sc", "events/usp.sc", "events/mac10.sc", "events/ump45.sc", "events/fiveseven.sc", "events/p90.sc", "events/deagle.sc", "events/p228.sc", "events/glock18.sc", "events/mp5n.sc", "events/tmp.sc", "events/elite_left.sc", "events/elite_right.sc", "events/galil.sc", "events/famas.sc" } public plugin_init() { register_plugin( "Bullet Kill", VERSION, "Pastout!" ) g_pCvar_Enabled = register_cvar("bulletkill_enable", "1")// 1 = on || 0 = off if ( !get_pcvar_num( g_pCvar_Enabled ) ) return; g_iMaxPlayers = get_maxplayers( ) new g_szPlayer[] = "player" RegisterHam( Ham_Spawn, g_szPlayer, "Ham_CBasePlayer_Spawn", .Post = true ) RegisterHam( Ham_Killed, g_szPlayer, "Ham_CBasePlayer_Killed", .Post = true ) RegisterHam( Ham_TraceAttack, g_szPlayer, "Ham_CBasePlayer_TraceAttack", .Post = false ) unregister_forward( FM_PrecacheEvent, g_fwid, 1 ) register_forward( FM_PlaybackEvent, "Fwd_Playback_Event" ) } public plugin_unpause() { is_Connected = 0; is_Alive = 0; static iPlayers[ 32 ], iNum, iPlayer get_players( iPlayers, iNum, "ch" ) for( new i = 0; i < iNum; i++ ) { iPlayer = iPlayers[ i ] SetBit( is_Connected, iPlayer ) if( is_user_alive( iPlayer ) ) { SetBit( is_Alive, iPlayer ) } } } public plugin_precache() g_fwid = register_forward( FM_PrecacheEvent, "Fwd_Precache_Event", 1 ) public Fwd_Precache_Event( type, const name[] ) { for( new i = 0; i < sizeof g_iGunEvents; ++i ) { if( equal( g_iGunEvents[ i ], name ) ) { g_iGunEvent_IDsBitsum |= ( 1 << get_orig_retval() ) return FMRES_HANDLED } } return FMRES_IGNORED } public Fwd_Playback_Event( flags, id, eventid ) { if( !( g_iGunEvent_IDsBitsum & ( 1 << eventid ) ) || !IsPlayer( id ) ) return FMRES_IGNORED; DelBit( iKillerShot, id ) g_iShotKills[ id ] = 0 return FMRES_HANDLED } public Ham_CBasePlayer_TraceAttack( this, iAttacker, Float:damage, Float:direction[ 3 ], traceresult, damagebits ) { if( GetBit( is_Connected, iAttacker ) && GetBit( is_Alive, iAttacker ) ) { static g_iWeapon; g_iWeapon = get_user_weapon( iAttacker ) if( g_iWeapon == CSW_KNIFE || g_iWeapon == CSW_HEGRENADE ) { return HAM_HANDLED } SetBit( iKillerShot, iAttacker ) } return HAM_HANDLED } public Ham_CBasePlayer_Killed( iVictim, iKiller ) { if( GetBit( is_Alive, iKiller ) && GetBit( is_Connected, iVictim ) && GetBit( iKillerShot, iKiller ) ) { g_iShotKills[ iKiller ]++ if( g_iShotKills[ iKiller ] >= 2 ) { new szName[ 32 ]; get_user_name( iKiller, szName, charsmax( szName ) ); client_print( 0, print_chat, "%s killed %d players with one stone", szName, g_iShotKills[ iKiller ] ) g_iShotKills[ iKiller ] = 0 } } } public Ham_CBasePlayer_Spawn( id ) { if( !is_user_alive( id ) ) return HAM_IGNORED; SetBit( is_Alive, id ) return HAM_IGNORED; } public client_putinserver( id ) { SetBit( is_Connected, id ); DelBit( is_Alive, id ); } public client_disconnect( id ) { DelBit( is_Connected, id ); DelBit( is_Alive, id ); }
|