Code: Select all
/* AMX Mod script* * (c) 2002-2003, DynAstY* This file is provided as is (no warranties).** Players with immunity won't be checked*//** Full Respect to DynAstY for this little plugin.* Only Added Multilanguage support and changed the disconnect handling.* This is a amx port. engine module isn't needed anymore.* Cheers CRAZyBUg* v.1.2.2 - amxx port, multilanguage support, disconnect handling*/ #include <amxmodx> new HIGHPING_MAX = 120 // set maximal acceptable pingnew HIGHPING_TIME = 15 // set in seconds frequency of ping checkingnew HIGHPING_TESTS = 3 // minimal number of checks before doing anything new msg_saytext; new iNumTests[33] public plugin_init() { register_plugin("High Ping Kicker","1.2.2","DynAstY") register_dictionary("hpk.txt") msg_saytext = get_user_msgid("SayText") return PLUGIN_CONTINUE} public client_disconnect(id) { remove_task(id) return PLUGIN_CONTINUE} public client_putinserver(id) { iNumTests[id] = 0 if (!is_user_bot(id)) { new param[1] param[0] = id set_task(30.0, "showWarn", id, param, 1) } return PLUGIN_CONTINUE} kickPlayer(id) { new name[32] get_user_name(id, name, 31) new uID = get_user_userid(id) server_cmd("banid 1 #%d", uID) server_cmd("kick #%d %L", uID, id, "PING_KICK_PLAYER_MSG")// client_cmd(id, "echo ^"%L ^"; disconnect", id, "PING_KICK_PLAYER_MSG") client_printcolor(0, "%L", LANG_PLAYER, "PING_KICK_PUBLIC_MSG", name) return PLUGIN_CONTINUE} public checkPing(param[]) { new id = param[0] if ( get_user_flags(id) & ( ADMIN_RESERVATION | ADMIN_LEVEL_A ) ) { remove_task(id) client_printcolor(id, "%L", id, "PING_IMMUNITY_MSG") return PLUGIN_CONTINUE } new p, l get_user_ping(id, p, l) if (p > HIGHPING_MAX) ++iNumTests[id] else if (iNumTests[id] > 0) --iNumTests[id] if (iNumTests[id] > HIGHPING_TESTS) kickPlayer(id) return PLUGIN_CONTINUE} public showWarn(param[]) { client_print(param[0], print_chat, "%L", param[0], "PING_ANNOUNCE_MSG", HIGHPING_MAX) set_task(float(HIGHPING_TIME), "checkPing", param[0], param, 1, "b") return PLUGIN_CONTINUE} stock client_printcolor(id, const message[], any:...){ static buffer[512], argscount argscount = numargs() if (!id) { static players[32], num, player, i, i2 get_players(players, num , "ch") for (i = 0; i < num; i++) { player = players[i] static changed[5], changedcount changedcount = 0 for (i2 = 2; i2 < argscount; i2++) { if (getarg(i2) == LANG_PLAYER) { setarg(i2, 0, player) changed[changedcount] = i2 changedcount++ } } vformat(buffer, charsmax(buffer), message, 3) replace_all(buffer, charsmax(buffer), "/g", "^4") replace_all(buffer, charsmax(buffer), "/y", "^1") replace_all(buffer, charsmax(buffer), "/t", "^3") message_begin(MSG_ONE_UNRELIABLE, msg_saytext, _, player) write_byte(player) write_string(buffer) message_end() for (i2 = 0; i2 < changedcount; i2++) setarg(changed[i2], 0, LANG_PLAYER) } } else { vformat(buffer, charsmax(buffer), message, 3) replace_all(buffer, charsmax(buffer), "/g", "^4") replace_all(buffer, charsmax(buffer), "/y", "^1") replace_all(buffer, charsmax(buffer), "/t", "^3") message_begin(MSG_ONE_UNRELIABLE, msg_saytext, _, id) write_byte(id) write_string(buffer) message_end() }}