Code:
#include < amxmodx >
#include < hamsandwich >
new deaths[ 33 ], cvar_limit;
// Init
public plugin_init()
{
// Register
register_plugin( "AutoKick Players", "1.0", "monster321" )
// Events
register_event( "DeathMsg", "ev_deathmsg", "a" )
// Hams
RegisterHam( Ham_Killed, "player", "HamPlayerKilled" )
// Cvars
cvar_limit = register_cvar( "akp_limit_deaths", "5" )
}
// Client connect
public client_connect( id )
deaths[ id ] = 0;
// EV DeathMsg
public ev_deathmsg()
{
new id, vic;
id = read_data( 1 )
vic = read_data( 2 )
static weapon[ 16 ];
read_data( 4, weapon, sizeof( weapon ) - 1 )
if( !id )
{
if( equal( weapon, "world", 5 ) || equal( weapon, "door", 4 ) || equal( weapon, "trigger_hurt", 12 ) || equal( weapon, "train", 5 ) || equal( weapon, "env_beam", 8 ) || equal( weapon, "env_laser", 9 ) || equal( weapon, "vehicle", 7 ) || equal( weapon, "", 7 ) )
{
deaths[ vic ] ++;
check_deaths( vic )
}
}
}
// HamPlayerKilled
public HamPlayerKilled( vic, id, gib )
{
if( !is_user_connected( id ) )
return HAM_IGNORED;
deaths[ vic ] ++;
check_deaths( vic )
return HAM_IGNORED;
}
// Check Deaths
public check_deaths( id )
{
if( !is_user_connected( id ) )
return PLUGIN_HANDLED;
if( get_user_frags( id ) == 0 && deaths[ id ] == get_pcvar_num( cvar_limit ) )
server_cmd( "kick #%d ^"[ AKP ] You died %d times^"", get_user_userid( id ), get_pcvar_num( cvar_limit ) )
return PLUGIN_HANDLED;
}