Code:
#include <amxmodx>
#define MAX_CLIENTS 32
#define MAX_SUICIDE 10
new g_iSuicideCnt[ MAX_CLIENTS + 1 ] = { MAX_SUICIDE, ... };
public plugin_init()
{
register_plugin( "Anti-Death Kicker", "1.0", "FiVeTeN" );
register_event( "DeathMsg", "onDeath", "a" ); // Suicide
register_event( "TextMsg" , "eResetCount", "a", "2=#Game_will_restart_in" ); // Restart attempt
register_event( "HLTV" , "eResetCount", "a", "1=0", "2=0" ); // New round
}
public onDeath()
{
new iKiller = read_data( 1 );
new iVictim = read_data( 2 );
static sWeapon[6];
read_data( 4, sWeapon, sizeof sWeapon - 1 );
if( iKiller == iVictim && equal( sWeapon, "world", 5 ) )
{
--g_iSuicideCnt[ iVictim ];
if( !g_iSuicideCnt[ iVictim ] )
server_cmd( "kick #%d Your message here", get_user_userid( iVictim ) );
client_print( iVictim, print_chat, "[AMXX] Careful! You have %d suicide%s left.", g_iSuicideCnt[ iVictim ], g_iSuicideCnt[ iVictim ] < 2 ? "" : "s" );
}
}
public eResetCount()
arrayset( g_iSuicideCnt, MAX_SUICIDE, sizeof g_iSuicideCnt );
public client_disconnect( id )
g_iSuicideCnt[id] = MAX_SUICIDE;