|
本帖最后由 eason39 于 2009-2-26 05:12 编辑
一般人都不知道按控制台出来看信息,如果做到踢出后 有对话框显示,比如"你以被服务器踢出,原因ping值太高!这样。- #include <amxmodx>
- new g_Ping[33]
- new g_Samples[33]
- new pamx_hpk_ping
- new pamx_hpk_check
- new pamx_hpk_tests
- new pamx_hpk_delay
- public plugin_init()
- {
- register_plugin("High Ping Kicker","1.0","datang")
- register_dictionary("high_ping_kicker.txt")
- pamx_hpk_ping = register_cvar("amx_hpk_ping","200")
- pamx_hpk_check = register_cvar("amx_hpk_check","5")
- pamx_hpk_tests = register_cvar("amx_hpk_tests","5")
- pamx_hpk_delay = register_cvar("amx_hpk_delay","60")
-
- if ( get_pcvar_num( pamx_hpk_check ) < 5 ) set_pcvar_num( pamx_hpk_check , 5 )
- if ( get_pcvar_num( pamx_hpk_tests ) < 3 ) set_pcvar_num( pamx_hpk_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( 10.0 , "showWarn" , id , param , 1 )
-
- if (get_pcvar_num(pamx_hpk_delay) != 0) {
- set_task( float(get_pcvar_num(pamx_hpk_delay)), "taskSetting", id, param , 1)
- }
- else {
- set_task( float(get_pcvar_num( pamx_hpk_check )) , "checkPing" , id , param , 1 , "b" )
- }
- }
- }
- public showWarn(param[]) {
- client_print( param[0] ,print_chat,"* %L",LANG_SERVER,"PING", get_pcvar_num( pamx_hpk_ping ) )
- console_print( param[0],"* %L",LANG_SERVER,"PING", get_pcvar_num( pamx_hpk_ping ) )
- }
- public taskSetting(param[]) {
- set_task( float(get_pcvar_num( pamx_hpk_check )) , "checkPing" , param[0] , param , 1 , "b" )
- }
- kickPlayer( id )
- {
- new name[32],authid[32]
- new userid = get_user_userid(id)
- get_user_name(id,name,31)
- get_user_authid(id,authid,31)
- client_print(0,print_chat,"* %L", id, "KICKED", name)
- log_amx("^"%s<%d><%s><>^" has been kicked due to high ping.", name, userid, authid)
- client_cmd(id, "echo ^"* %L^"", id, "HPK")
- client_cmd(id, "disconnect") //Has no effects in CS1.5
- server_cmd("kick #%d", userid) //So kicked
- remove_task(id)
- }
- public checkPing(param[])
- {
- new id = param[ 0 ]
- if ( get_user_flags(id) & ADMIN_IMMUNITY || get_user_flags(id) & ADMIN_RESERVATION ) return
- new p, l
- get_user_ping( id , p , l )
- g_Ping[ id ] += p
- ++g_Samples[ id ]
- if ( (g_Samples[ id ] >= get_pcvar_num( pamx_hpk_tests )) && (g_Ping[id] / g_Samples[id] > get_pcvar_num( pamx_hpk_ping )) )
- kickPlayer(id)
- }
复制代码 |
|