Announcement

Collapse
No announcement yet.

mm_Squadless_Kick.py HELP

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • mm_Squadless_Kick.py HELP

    cant seem to get this to work whit modManager. im getting message, "invalid syntax, line 1"

    [CODE]
    # vim: ts=4 sw=4 noexpandtab
    """Squadless Kick System
    Kicks a player from the server if they have not joined a squad in a specified interval.

    ===== Config =====
    # Sets time between spawning without a squad and being kicked
    mm_squadless_kick kick_time 90
    # Sets interval time to remind a player before being kicked
    mm_squadless_kick reminder_interval 15

    ===== History =====
    v2.2 - 30/08/2006 Created by Sean 'pokerface' Steeg.
    updated kicks and bans to tg_bf2_common (for pb kicks)

    v2.1 - 17/08/2005 Created by Sean 'pokerface' Steeg.
    updated to modmanager layout
    added reminder time

    v2.0: Created by Sean 'pokerface' Steeg.
    Changed to use a timer from player spawn instead of death. Thanks, Sarc.

    v1.0: Created by Sean 'pokerface' Steeg.
    Buggy and ran off of player death.
    """

    import bf2
    import host
    import tg_bf2_common
    from tg_bf2_common import tg_debug
    import mm_utils
    import string

    #import sys
    #sys.stderr = tg_bf2_common.FileError()

    __version__ = 2.2
    __author__ = "Sean Steeg <sean at steegness dot com>"
    __required_modules__ = {'modmanager': 1.0}
    __supports_reload__ = True
    __description__ = "TacticalGamer Squadless Kick v%s" % __version__

    configDefaults = {'kick_time': 90,
    'reminder_interval': 15}

    class Squadless_Kicker(object):
    def __init__ (self, modManager):
    """Create a new instance."""
    self.mm = modManager
    self.__state = 0

    def checkSquadless(self, p):
    #Check that the player is squadless AND is not the comm
    if str(p.getSquadId()) == '0' and (not p.isCommander()):
    #increment the time for the player
    p.timeElapsed += self.reminderTime
    if p.timeElapsed < self.kickTime:
    if tg_debug: print 'Elapsed Time on %s: %d KickTime: %d' %(p.getName(), p.timeElapsed, self.kickTime)
    #Still in the grace period. Send a warning via global chat.
    kicknotice = "c1001 ********** %s has %s seconds to join a squad or be kicked.**********" % (string.upper(p.getName()), str(self.kickTime - p.timeElapsed))
    mm_utils.msg_server(kicknotice)
    else:
    if tg_debug: print 'Squadless Time elapsed on player %s' % p.getName()
    #time's up. begone, squadless person.
    kicknotice = "c1001 ********** %s is being kicked (squadless)**********" % string.upper(p.getName())
    if tg_debug: print 'Kicknotice created for player %s' % p.getName()
    mm_utils.msg_server(kicknotice)
    if tg_debug: print 'Serverwide kicknotice sent for player %s' % p.getName()
    if tg_debug: print 'About to kick %s for being squadless' % p.getName()
    tg_bf2_common.pb_kick(p.getName(), "Joining a squad is a requirement on this server.")
    if tg_debug: print 'PB kick issued on %s' % p.getName()
    if tg_debug: print 'Destroying Timers'
    if self.squadlesstimer:
    self.squadlesstimer.destroy()
    self.squadlesstimer = None
    if self.remindtimer:
    self.remindtimer.destroy()
    self.remindtimer = None
    else:
    if self.squadlesstimer:
    self.squadlesstimer.destroy()
    self.squadlesstimer = None
    if self.remindtimer:
    self.remindtimer.destroy()
    self.remindtimer = None

    #EVENTS
    def onPlayerSpawn(self, p, soldier):
    if self.__state != 1:
    return 0

    #on spawn, if a player is squadless, teamsay a warning (covered in checkSquadless for subsequent calls)
    p.timeElapsed = 0
    if (str(p.getSquadId()) == '0') and (not p.isCommander()):
    kicknotice = "c1001 ********** %s has %s seconds to join a squad or be kicked.**********" % (string.upper(p.getName()), str(self.kickTime))
    mm_utils.msg_server(kicknotice)
    self.squadlesstimer = bf2.Timer(self.checkSquadless, self.reminderTime, 1, p)
    self.squadlesstimer.setRecurring(self.reminderTime )

    #INIT / SHUTDOWN
    def init(self):
    if tg_debug: print 'initializing squadless_kick script'
    """Provides default initialization."""
    self.__config = self.mm.getModuleConfig(configDefaults)
    self.kickTime = self.__config['kick_time']
    self.reminderTime = self.__config['reminder_interval']
    self.squadlesstimer = None
    self.timeelapsed = 0

    if self.__state == 0:
    host.registerHandler('PlayerSpawn', self.onPlayerSpawn)

    self.__state = 1
    if tg_debug: print 'squadless kick successfully initialized.'

    def shutdown(self):
    """Shutdown and stop processing."""
    if self.squadlesstimer:
    self.squadlesstimer.destroy()
    self.squadlesstimer = None

    self.__state = 2

    def mm_load(modManager):
    """Creates a Squadless Kick object."""
    return Squadless_Kicker(modManager)
    [CODE/]
    Last edited by Digi24; 09-24-2007, 08:02 AM.

  • #2
    Re: mm_Squadless_Kick.py HELP

    Nvm. Got it working

    Comment


    • #3
      Re: mm_Squadless_Kick.py HELP

      Awesome! Solved before I noticed the thread! Rock on.
      [volun2]
      NS Game Officer. TF2 Admin. BF2 Admin / Scripter. PM with issues.
      Tempus: Pokerface is nailing it right on the head. Everyone who is arguing against him is simply arguing against reality.
      <anmuzi> it is not permitted to have privacy or anonymity
      <LazyEye> yeah when I play on TG the server digs though my trash

      Arm yourself with knowledge: TG NS TF2 BF2

      Comment

      Connect

      Collapse

      TeamSpeak 3 Server

      Collapse

      Advertisement

      Collapse

      Twitter Feed

      Collapse

      Working...
      X