|
发表于 2004-8-9 21:10:21
|
显示全部楼层
来自 中国–浙江–宁波–余姚市
/* AMX Mod script.
*
* (c) 2002-2003, OLO
* This file is provided as is (no warranties).
*
* Players with immunity won't be checked
*/
#include <amxmod>
new HIGHPING_MAX = 100 // set maximal acceptable ping
new HIGHPING_TIME = 12 // set in seconds frequency of ping checking
new HIGHPING_TESTS = 5 // minimal number of checks before doing anything
new g_Ping[33]
new g_Samples[33]
public plugin_init()
{
register_plugin("High Ping Kicker","0.9.4","default")
if ( HIGHPING_TIME < 5 ) HIGHPING_TIME = 5
if ( HIGHPING_TESTS < 3 ) HIGHPING_TESTS = 3
}
public client_disconnect(id)
remove_task( id )
public client_putinserver(id)
{
g_Ping[id] = 0
g_Samples[id] = 0
if ( !is_user_bot(id) )
{
new param[1]
param[0] = id
set_task( float(HIGHPING_TIME) , "checkPing" , id , param , 1 , "b" )
set_task( 10.0 , "showWarn" , id , param , 1 )
}
}
kickPlayer( id )
{
new name[32]
get_user_name( id , name , 31 )
client_print(0,print_chat,"** Player %s disconnected due to high ping",name)
client_cmd(id,"echo ^"** Sorry but you have too high ping, try later...^";disconnect")
}
public checkPing(param[])
{
new id = param[ 0 ]
if ( get_user_flags(id) & ADMIN_IMMUNITY ) return // has immunity
new p, l
get_user_ping( id , p , l )
g_Ping[ id ] += p
++g_Samples[ id ]
if ( (g_Samples[ id ] > HIGHPING_TESTS) &&
(g_Ping[id] / g_Samples[id] > HIGHPING_MAX) )
kickPlayer(id)
}
public showWarn(param[])
client_print( param[0] ,print_chat,"* Players with ping higher than %d will be kicked!", HIGHPING_MAX )
修改这里
new HIGHPING_MAX = 100 // set maximal acceptable ping |
|