#include <amxmod>
new origupdr[33], origrate[33], excl[33]
#define MAX_IP 32
new ignip[MAX_IP][32], ippos=0
#define MAX_WONID 128
new ignwonid[MAX_WONID], wonidpos=0
public check_rr() {
new maxupdr=get_cvar_num("rm_maxupdr")
new minupdr=get_cvar_num("rm_minupdr")
new maxrate=get_cvar_num("rm_maxrate")
new minrate=get_cvar_num("rm_minrate")
new announce=get_cvar_num("rm_announce")
new players[32], np, i, playername[32]
new clupdr[8], clrt[16], msg[256]
new tmpupdr, tmprate, cmdexe[32]
get_players(players, np, "ac")
for(i=0; i<np; i++)
if ((players[i]!=0)&&(!is_user_hltv(players[i]))) {
get_user_ping(players[i], tmpupdr, tmprate)
if ((tmpupdr>get_cvar_num("rm_localping"))&&(excl[players[i]]==0)) {
get_user_info(players[i], "cl_updaterate", clupdr, 7)
get_user_info(players[i], "rate", clrt, 15)
tmpupdr=str_to_num(clupdr)
tmprate=str_to_num(clrt)
if (announce)
get_user_name(players[i],playername,31)
if (tmpupdr>maxupdr) {
origupdr[players[i]]=maxupdr
format(cmdexe, 31, "cl_updaterate %i", maxupdr)
client_cmd(players[i], cmdexe)
if (announce) {
format(msg, 255, "* [<<eb@>>] %s set 'cl_updaterate' to '%i' (max '%i') - blocked by plugin !", playername, tmpupdr, maxupdr)
client_print(0, print_chat, msg)
}
}
if (tmpupdr<minupdr) {
origupdr[players[i]]=minupdr
format(cmdexe, 31, "cl_updaterate %i", minupdr)
client_cmd(players[i], cmdexe)
if (announce) {
format(msg, 255, "* [<<eb@>>] %s set 'cl_updaterate' to '%i' (min '%i') - blocked by plugin !", playername, tmpupdr, minupdr)
client_print(0, print_chat, msg)
}
}
if (tmprate>maxrate) {
origrate[players[i]]=maxrate
format(cmdexe, 31, "rate %i", maxrate)
client_cmd(players[i], cmdexe)
format(cmdexe, 31, "cl_rate %i", maxrate)
client_cmd(players[i], cmdexe)
if (announce) {
format(msg, 255, "* [<<eb@>>] %s set 'rate' to '%i' (max '%i') - blocked by plugin !", playername, tmprate, maxrate)
client_print(0, print_chat, msg)
}
}
if (tmprate<minrate) {
origrate[players[i]]=minrate
format(cmdexe, 31, "rate %i", minrate)
client_cmd(players[i], cmdexe)
format(cmdexe, 31, "cl_rate %i", minrate)
client_cmd(players[i], cmdexe)
if (announce) {
format(msg, 255, "* [AMX_RM] %s set 'rate' to '%i' (min '%i') - blocked by plugin !", playername, tmprate, minrate)
client_print(0, print_chat, msg)
}
}
}
}
new Float:freq=get_cvar_float("rm_delay")
if (freq > 0.0) set_task(freq, "check_rr")
return PLUGIN_CONTINUE
}
public alive_again(id) {
if ((is_user_bot(id))||(is_user_hltv(id)))
return PLUGIN_CONTINUE
if (excl[id]==1)
return PLUGIN_CONTINUE
new Float:ratio=get_cvar_float("rm_deadratio")
if (ratio==1.0)
return PLUGIN_CONTINUE
new ping, loss
get_user_ping(id, ping, loss)
if (ping>get_cvar_num("rm_localping")) {
new cmdexe[32]
format(cmdexe, 31, "cl_updaterate %i", origupdr[id])
client_cmd(id, cmdexe)
format(cmdexe, 31, "rate %i", origrate[id])
client_cmd(id, cmdexe)
format(cmdexe, 31, "cl_rate %i", origrate[id])
client_cmd(id, cmdexe)
if (get_cvar_num("rm_announce")) {
new msg[256]
format(msg, 255, "* [AMX_RM] Your net settings have been restored : 'cl_updaterate' = '%i', 'rate' = '%i'", origupdr[id], origrate[id])
client_print(id, print_chat, msg)
}
}
return PLUGIN_CONTINUE
}
public dead_now() {
new victim=read_data(2)
if ((is_user_bot(victim))||(is_user_hltv(victim)))
return PLUGIN_CONTINUE
if (excl[victim]==1)
return PLUGIN_CONTINUE
new Float:ratio=get_cvar_float("rm_deadratio")
if (ratio==1.0)
return PLUGIN_CONTINUE
new tmpupdr, tmprate
get_user_ping(victim, tmpupdr, tmprate)
if (tmpupdr>get_cvar_num("rm_localping")) {
new cmdexe[32]
tmpupdr=floatround(float(origupdr[victim])*ratio)
tmprate=floatround(float(origrate[victim])*ratio)
format(cmdexe, 31, "cl_updaterate %i", tmpupdr)
client_cmd(victim, cmdexe)
format(cmdexe, 31, "rate %i", tmprate)
client_cmd(victim, cmdexe)
format(cmdexe, 31, "cl_rate %i", tmprate)
client_cmd(victim, cmdexe)
if (get_cvar_num("rm_announce")) {
new msg[256]
format(msg, 255, "* [AMX_RM] Your net settings have been lowered : 'cl_updaterate' = '%i', 'rate' = '%i'", tmpupdr, tmprate)
client_print(victim, print_chat, msg)
}
}
return PLUGIN_CONTINUE
}
public ignore_ip(id) {
new argc=read_argc()
if (argc<2) {
console_print(id, "Usage: rm_ignoreip <IP> [IP] [IP] [IP] ...")
return PLUGIN_CONTINUE
}
for(new i=1; i<argc; i++)
if (ippos<MAX_IP) {
read_argv(i, ignip[ippos], 31)
ippos++
}
else {
console_print(id, "* [AMX_RM] Too many IP addresses added to the ignore IP list")
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
public ignore_wonid(id) {
new argc=read_argc()
if (argc<2) {
console_print(id, "Usage: rm_ignorewonid <WonID> [WonID] [WonID] [WonID] ...")
return PLUGIN_CONTINUE
}
new tmp[32]
for(new i=1; i<argc; i++)
if (wonidpos<MAX_WONID) {
read_argv(i, tmp, 31)
ignwonid[wonidpos]=strtonum(tmp)
wonidpos++
}
else {
console_print(id, "* [AMX_RM] Too many WonIDs added to the ignore WonID list")
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
public client_connect(id) {
if ((is_user_bot(id))||(is_user_hltv(id)))
return PLUGIN_CONTINUE
new clupdr[8], clrt[16]
get_user_info(id, "cl_updaterate", clupdr, 7)
get_user_info(id, "rate", clrt, 15)
origupdr[id]=str_to_num(clupdr)
origrate[id]=str_to_num(clrt)
excl[id]=0
new i
if (ippos>0) {
new userip[32]
get_user_ip(id, userip, 31)
copyc(userip, 31, userip, ':')
new len
for(i=0; i<ippos; i++) {
len=containi(ignip[i],".x")
if (len>-1) {
if (equal(userip, ignip[i], len)) {
excl[id]=1
break
}
}
else if (equal(userip, ignip[i])) {
excl[id]=1
break
}
}
}
if ((wonidpos>0)&&(excl[id]==0)) {
new wonid=0
wonid=get_user_wonid(id)
if (wonid>0)
for(i=0; i<wonidpos; i++)
if (wonid==ignwonid[i]) {
excl[id]=1
break
}
}
if (get_cvar_num("rm_hello")==0)
return PLUGIN_CONTINUE
new plgver[16]
get_cvar_string("rate_manager", plgver, 15)
client_cmd(id, "echo ======================================================================")
client_cmd(id, "echo ^"* AMX Rate Manager v%s *^"", plgver)
new Float:freq=get_cvar_float("rm_delay")
if (freq>0.0) {
new maxupdr=get_cvar_num("rm_maxupdr")
new minupdr=get_cvar_num("rm_minupdr")
new maxrate=get_cvar_num("rm_maxrate")
new minrate=get_cvar_num("rm_minrate")
client_cmd(id, "echo ^" - allowed 'cl_updaterate' range : '%i' - '%i', you have '%i'^"", minupdr, maxupdr, origupdr[id])
client_cmd(id, "echo ^" - allowed 'rate' range : '%i' - '%i', you have '%i'^"", minrate, maxrate, origrate[id])
}
new Float:ratio=get_cvar_float("rm_deadratio")
if (ratio<1.0)
client_cmd(id, "echo ^" - dead players use %2.0f%%%% of their normal net settings^"", (ratio*100.0))
client_cmd(id, "echo ======================================================================")
return PLUGIN_CONTINUE
}
public client_disconnect(id) {
if ((is_user_bot(id))||(is_user_hltv(id)))
return PLUGIN_CONTINUE
origupdr[id]=get_cvar_num("rm_minupdr")
origrate[id]=get_cvar_num("rm_minrate")
excl[id]=0
return PLUGIN_CONTINUE
}
public set_servercvars() {
new tmp[16]
get_cvar_string("rm_exclmaxupdr", tmp, 15)
set_cvar_string("sv_maxupdaterate", tmp)
get_cvar_string("rm_exclminupdr", tmp, 15)
set_cvar_string("sv_minupdaterate", tmp)
get_cvar_string("rm_exclmaxrate", tmp, 15)
set_cvar_string("sv_maxrate", tmp)
get_cvar_string("rm_exclminrate", tmp, 15)
set_cvar_string("sv_minrate", tmp)
if (get_cvar_num("rm_announce"))
console_print(0, "* [AMX_RM] Bandwith limits for excluded players have been set")
return PLUGIN_CONTINUE
}
public plugin_init() {
register_plugin("Rate Manager", "1.2", "Marach")
register_cvar("rate_manager", "1.2", FCVAR_SERVER)
register_event("ResetHUD", "alive_again", "be","1=1")
register_event("DeathMsg","dead_now","a")
register_cvar("rm_maxupdr", "101")
register_cvar("rm_minupdr", "101")
register_cvar("rm_maxrate", "25000")
register_cvar("rm_minrate", "25000")
register_cvar("rm_exclmaxupdr", "60")
register_cvar("rm_exclminupdr", "24")
register_cvar("rm_exclmaxrate", "15360")
register_cvar("rm_exclminrate", "6144")
register_cvar("rm_delay", "20")
register_cvar("rm_deadratio", "0.4")
register_cvar("rm_localping", "0")
register_cvar("rm_announce", "1")
register_cvar("rm_hello", "1")
register_srvcmd("rm_ignoreip", "ignore_ip")
register_srvcmd("rm_ignorewonid", "ignore_wonid")
new Float:freq=get_cvar_float("rm_delay")
if (freq>0.0) {
set_task(freq, "check_rr")
set_task(5.0, "set_servercvars")
}
return PLUGIN_CONTINUE
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1038\\ f0\\ fs16 \n\\ par }
*/