[bf1942] How to test high ping kicker is working
Paul Bowsher
paul.bowsher at gmail.com
Tue Jun 28 04:58:11 EDT 2005
Your bfno.py script in bf2/admin needs to be the bfno script provided,
not a set of config variables. Check the links further up/down
On 6/28/05, Nicolo Tüllmann <Nico at immortalesclan.de> wrote:
> Can enybody make a step be step instuction for a default Server please ?
>
> I make in the dirctory bf2/mods/bf2/settings
> the file adminsettings.com
>
> bfno.highPingAutoKick 1
> bfno.highPingLimit 20
> bfno.highPingWarnings 3
> bfno.highPingCheckInterval 30
>
>
> then i make in the serversettings.con
> sv.adminScript "bfno.py"
>
> Now in the direktory
> bf2/admin the file
> bfno.py
>
> bfno.highPingAutoKick 1
> bfno.highPingLimit 20
> bfno.highPingWarnings 3
> bfno.highPingCheckInterval 30
>
> now in the pfad
> bf2/admin/standard_admin edit the file __init__.py
>
> import autobalance
> import tk_punish
> import bf2cc
> import pingkick.py
>
> autobalance.init()
> tk_punish.init()
> pingkick.init()
>
> Now in the pfad bf2/admin/standard i make a file it calls pingkick.py
> # ------------------------------------------------------------------------
> # Module: pingkick.py
> # Authors: Kybber and Panic, Battlefield.no
> # Version 1.0
> # Description:
> # This script kicks players with high ping, based on three different
> # settings in the file 'adminsettings.con', loaded by the modified admin
> # script (sv.adminScript = bfno_v1.1.py). See requirements for details.
> # Requirements:
> # 1. The Battlefield.no modified admin script (bfno_v1.1.py) v1.1
> # 2. The file adminsettings.con (see 1) with the following settings:
> # - bfno.highPingAutoKick <1|0>
> # - bfno.highPingLimit <integer>
> # - bfno.highPingWarnings <integer>
> # Installation:
> # Place this script in your <bf2>/admin/standard_admin directory, and
> # add the lines 'import pingkick' and 'pingkick.init()' to the file
> # '<bf2>/admin/standard_admin/__init__.py'.
> # ------------------------------------------------------------------------
>
>
> # ------------------------------------------------------------------------
> # I M P O R T
> # ------------------------------------------------------------------------
>
> import host
> import bf2
> from bf2 import g_debug
>
> # ------------------------------------------------------------------------
> # V A R I A B L E S
> # ------------------------------------------------------------------------
>
> # We need a timer for our ping kicking:
> pktimer = 30
>
> # Interval between ping checks (overridden by
> bf2.adminoptions['bfno.highPingCheckInterval']):
> interval = 30
>
> # ------------------------------------------------------------------------
> # F U N C T I O N S
> # ------------------------------------------------------------------------
>
>
> # ------------------------------------------------------------------------
> # The init function run by the standard_admin/__init__ functions:
> # ------------------------------------------------------------------------
> def init():
> global pktimer
> global interval
> if g_debug: print 'PINGKICK: initializing pingkick script'
> autokick = None
> # Try to access the autokick setting:
> try:
> autokick = str(bf2.adminoptions['bfno.highPingAutoKick'])
> pinglimit = int(bf2.adminoptions['bfno.highPingLimit'])
> pingwarnings = int(bf2.adminoptions['bfno.highPingWarnings'])
> except:
> if g_debug: print "PINGKICK: WARNING - Could not get settings from
> 'bf2adminoptions'!"
> return False
>
> # Print debug message if autokick is disabled:
> if '1' != autokick:
> if g_debug: print 'PINGKICK: High ping autokick not enabled'
>
> # Autokick is enabled, so hook it up:
> else:
> if g_debug: print 'PINGKICK: Enabling kick for high ping: %s/%s'
> %(bf2.adminoptions['bfno.highPingLimit'],
> bf2.adminoptions['bfno.highPingWarnings'])
>
> # Register 'PlayerConnect' hook:
> host.registerHandler('PlayerConnect', onPlayerConnect, 1)
>
> # Reset TK Warnings
> for p in bf2.playerManager.getPlayers():
> onPlayerConnect(p)
>
> # PingKickTimer:
> enableTimer()
> # ------------------------------------------------------------------------
>
>
> # ------------------------------------------------------------------------
> # Enable the pktimer:
> # ------------------------------------------------------------------------
> def enableTimer():
> """Enables the timer that runs the 'checkPing' function which kicks
> high-pingers"""
> global pktimer
> if pktimer:
> return True
> else:
> # Try to read the ping check interval:
> try:
> interval = int(bf2.adminoptions['bfno.highPingCheckInterval'])
> if g_debug: print "PINGKICK: Interval set to " + str(interval)
> except:
> if g_debug: print "PINGKICK: WARNING - Could not get the
> 'bfno.highPingCheckInterval' setting. Not starting timer!"
> return False
> # Create the timer:
> if g_debug: print "PINGKICK: Timer not enabled. Enabling..."
> pktimer = bf2.Timer(checkPing, interval, 1)
> pktimer.setRecurring(10)
> # Print debug message telling the status of the timer:
> if pktimer:
> if g_debug: print "PINGKICK: Time = %s" % (pktimer.getTime())
> return True
> else:
> if g_debug: print "PINGKICK: Not enabled"
> return False
> # ------------------------------------------------------------------------
>
>
> # ------------------------------------------------------------------------
> # Loop all players, checking their ping, kick high-pinger:
> # ------------------------------------------------------------------------
> def checkPing(data):
> """Checks ping of all players, and kicks high-pingers"""
>
> # Make sure our timer is enabled:
> if not enableTimer(): return
>
> if g_debug: print "PINGKICK: Running checkPing"
>
> # Try to read the adminoptions dict from bf2
> # NB: This requires a modified version of the 'sv.adminScript'
> (default.py)
> # which again requires the 'adminsettings.con' file.
> try:
> limit = int(bf2.adminoptions['bfno.highPingLimit'])
> maxwarns = int(bf2.adminoptions['bfno.highPingWarnings'])
> except:
> return False
>
> if g_debug: print "PINGKICK: Ping-limit set to " + str(limit)
>
> # Loop all players
> for p in bf2.playerManager.getPlayers():
> name = str(p.getName())
> # Check if this player has reached the limit for maximum warnongs
> if maxwarns == p.pingWarnings:
> # Kick if limit is reached:
> print "PINGKICK: Kicking player " + name + " for high ping"
> result = host.rcon_invoke("admin.kickPlayer " + str(p.index))
> else:
> # Check the ping if the limit hasn't been reached:
> ping = None
> try:
> ping = p.getPing()
> except:
> pass
> # If we have a valid ping, check it, and issue a warning if the
> ping exceeds the limit:
> if ping:
> if g_debug: print "PINGKICK: " + name + " has " + str(ping) + "
> in ping and has " + str(p.pingWarnings) + " Ping-warnings"
> if ping > limit:
> p.pingWarnings += 1
> print "PINGKICK: Player " + name + " exceeds ping limit for
> the " + str(p.pingWarnings) + ". time"
> host.rcon_invoke("game.sayAll \"WARNING: " + name + " has
> exeeded the ping limit " + str(p.pingWarnings) + " time(s)\"")
> # Issue a warning if a player has reached the maximum number of
> warnings. Will be kicked next time 'checkPing' is run:
> if maxwarns == p.pingWarnings:
> host.rcon_invoke("game.sayAll \"Kicking player " + name + "
> for high ping\"")
> # ------------------------------------------------------------------------
>
>
> # ------------------------------------------------------------------------
> # Callback function for the "PlayerConnect" event:
> # ------------------------------------------------------------------------
> def onPlayerConnect(p):
> """Resets the ping warning counter for the player"""
> print "PINGKICK: Player connected"
> p.pingWarnings = 0 # Reset the 'TK Warnings' counter.
> # ------------------------------------------------------------------------
>
>
> now i start the server with the command
>
>
> screen ./start.sh
>
> But no kick with High Ping.
>
> Please help me
>
> Thanks for all
>
>
>
>
> ----- Original Message -----
> From: "Panic" <panic at battlefield.no>
> To: <bf1942 at icculus.org>
> Sent: Monday, June 27, 2005 10:20 PM
> Subject: Re: [bf1942] How to test high ping kicker is working
>
>
> > Hei Chris
> >
> > Christian wrote:
> >
> > >Hi Panic,
> > >
> > >you have a small typing error in the section "Creating the Admin
> > >Settings File" from the modified admin script ('default.py')
> > >
> > >adminsetting.con should be adminsettings.con
> > >
> > I've updated the wiki now. Thanks a lot for letting me know :-)
> >
> > ----------------------------------------------------------------------
> > Name: Frode Hommedal
> > Location: Norway
> > Day job: VLSI designer and programmer
> > Site: Battlefield.no [ http://www.battlefield.no ]
> > ----------------------------------------------------------------------
> > International Game Server Operators Association [ http://igsoa.com ]
> > ----------------------------------------------------------------------
> >
>
>
--
Paul Bowsher
IT Systems Developer
Simply Stuck Ltd
More information about the Bf1942
mailing list