kitshmily 发表于 2005-8-2 23:42:20

【转帖】服务器带宽控制(for amxx 1.0)

small /*
*Plugin By: OLO
*
* This file is provided as is (no warranties).
* Ported by VanillA Ice
*I take no credit in the making of this plugin...all i did was port it..
*
*/

/*
Controls sv_maxupdaterate (be wise with usage or you will get

pings worse).

cvars:
amx_ctrlupdaterate <value> - when players is more than that value

then
                                                            server starts to lowering

sv_udpdaterate                        
amx_maxupdaterate <value> -   this is what you want maximum

sv_updaterate to be
amx_minupdaterate <value> -   this is what you want minimum

sv_updaterate to be
*/

#include <amxmodx>

new low = 0
new udl = 0
new bool:calculate = true

public client_putinserver(id)
{
    if (calculate)
    {
      calculate = false
         
      new maxupd = get_cvar_num("amx_maxupdaterate")
      new minupd = get_cvar_num("amx_minupdaterate")
            
      new divv = get_maxplayers() - get_cvar_num

("amx_ctrlupdaterate")
            
      if (divv < 1)
            divv = 1
         
      low = (maxupd - minupd) / divv
      udl = maxupd
         
      set_cvar_num("sv_maxupdaterate",udl)
      /*server_print("sv_maxupdaterate set to %d",udl)*/
    }
      
    if ( get_playersnum() > get_cvar_num("amx_ctrlupdaterate") )
    {
      udl -= low
      set_cvar_num("sv_maxupdaterate",udl)
      /*server_print("sv_maxupdaterate set to %d",udl)*/
    }
         
    return PLUGIN_CONTINUE
}

public client_disconnect(id)
{
    /* get_playersnum still includes this id */
    if ( get_playersnum() >= get_cvar_num("amx_ctrlupdaterate") )
    {
      udl += low
      set_cvar_num("sv_maxupdaterate",udl)
      /*server_print("sv_maxupdaterate set to %d",udl)*/
    }
      
    return PLUGIN_CONTINUE
}

public plugin_init()
{
    register_plugin("Bandwidth Control","0.8.7","VanillA Ice")
    register_cvar("amx_ctrlupdaterate","8")
    register_cvar("amx_maxupdaterate","60")
    register_cvar("amx_minupdaterate","45")
    return PLUGIN_CONTINUE
}

downloadurlbandwithcontrolamxxx.amxx
downloadurl
bandwithcontrol.sma
downloadurl
bandwithcontrol.amxx
and you want see them

If you have these set in your server.cfg will it not kick or get rid of what the max is that you set?

Code:

//minrate
sv_minrate 0

//maxrate
sv_maxrate 6000

//maxupdaterate
sv_maxupdaterate 20

上面所说的是如何控制服务器连接带宽。
原文是:Plugin - Bandwith Control
页: [1]
查看完整版本: 【转帖】服务器带宽控制(for amxx 1.0)