Exemplo n.º 1
0
    def init(self):
        """Provides default initialisation."""

        # Load the configuration
        self.__config = self.mm.getModuleConfig(configDefaults)
        self.__maplists = self.__config["maplists"]
        self.__maplistPath = self.__config["maplistPath"]
        self.__force = self.__config["force"]
        self.__shuffle = self.__config["shuffle"]

        # Register your game handlers and provide any
        # other dynamic initialisation here

        if 0 == self.__state:
            # Register your host handlers here
            host.registerHandler("PlayerConnect", self.onPlayerConnect, 1)
            host.registerHandler("PlayerDisconnect", self.onPlayerDisconnect,
                                 1)
            host.registerGameStatusHandler(self.onGameStatusChanged)

        # Register our rcon command handlers
        # self.mm.registerRconCmdHandler( 'm', { 'method': self.cmdExec, 'subcmds': self.__cmds, 'level': 1 } ) # TODO: Disabled because see comment on top of the file

        # Update to the running state
        self.__state = 1
Exemplo n.º 2
0
def init():
    print 'LOGGER - INIT'

    # Build a path to the target log output file
    log_name = bf2.gameLogic.getModDir() + '/logs/' + '/bf2_game_log.txt'
    print 'Creating log file: ', log_name

    # Open the log file in line-buffered append mode
    global log_file
    try:
        log_file = open(log_name, 'a', 1)
    except IOError:
        print 'Unable to open log file: ', log_name
        return

    # Log the change in server status
    timestamp = datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
    log('SS', 'start', timestamp)

    # Register the pre-game callbacks
    host.registerHandler('PlayerConnect', on_connect, 1)
    host.registerHandler('PlayerDisconnect', on_disconnect, 1)
    host.registerHandler('Reset', on_reset, 1)

    # Register the game status callback
    host.registerGameStatusHandler(on_game_status)
Exemplo n.º 3
0
def enable():
	global fileName
	global logfile
	global startTime

	if logfile and not logfile.closed:
		print "Fragalyzer logging already enabled"
		return 
		
	host.registerGameStatusHandler(onGameStatusChanged)
	
	currentDate = datetime.datetime.today()
	dateString = ""
	dateString = time.strftime("%y%m%d_%H%M", currentDate.timetuple())

	if dateString != "":
		fileName = bf2.gameLogic.getModDir() + "/Logs/" + bf2.gameLogic.getMapName() + "_" + dateString + "_faLog.txt"
	else:
		fileName = bf2.gameLogic.getModDir() + "/Logs/" + bf2.gameLogic.getMapName() + "_faLog.txt"
		
	fileName = fileName.replace('/', '\\')
	
	print "log file: ", fileName

	try:
		logfile = file (fileName, 'w')
	except Exception:
		if g_debug: print "Couldnt open fragalyzer logfile: ", fileName
		return
	
	startTime = int(date())
	timeString = str(startTime)
	startDate = time.strftime("%Y.%m.%d,%H:%M", currentDate.timetuple())
	logfile.write("INIT LevelName=" + bf2.gameLogic.getMapName() + " StartTime=" + timeString + " StartDate=" + startDate + " Filename=" + fileName + "\n")
		
	logfile.flush()


	# register events
	host.registerHandler('PlayerKilled', onPlayerKilled)
	host.registerHandler('PlayerDeath', onPlayerDeath)
	host.registerHandler('EnterVehicle', onEnterVehicle)
	host.registerHandler('ExitVehicle', onExitVehicle)
	host.registerHandler('PickupKit', onPickupKit)
	host.registerHandler('DropKit', onDropKit)
	host.registerHandler('ControlPointChangedOwner', onCPStatusChange)
	host.registerHandler('PlayerScore', onPlayerScore)
	host.registerHandler('PlayerSpawn', onPlayerSpawn)

	host.registerHandler('PlayerConnect', onPlayerConnect, 1)

	host.registerHandler('DeployGrapplingHook', onDeployGrapplingHook)
	host.registerHandler('DeployZipLine', onDeployZipLine)
	host.registerHandler('DeployTactical', onDeployTactical)
	
	# Connect already connected players if reinitializing
	for p in bf2.playerManager.getPlayers():
		onPlayerConnect(p)
	
	print "Fragalyzer logging enabled."
Exemplo n.º 4
0
    def init(self):
        """Provides default initialisation."""

        # Load the configuration
        self.__config = self.mm.getModuleConfig(configDefaults)
        self.__banFileName = self.mm.configPath(
        ) + '/' + self.__config['banFilename']

        # Load the bans
        self.loadBans()

        # Register our base handlers
        host.registerGameStatusHandler(self.onGameStatusChanged)

        # Register our rcon command handlers
        self.mm.registerRconCmdHandler('bm', {
            'method': self.cmdExec,
            'subcmds': self.__cmds,
            'level': 1
        })

        if 0 == self.__state:
            host.registerHandler('PlayerDisconnect', self.onPlayerDisconnect,
                                 1)

        # Register your game handlers and provide any
        # other dynamic initialisation here

        # Update to the running state
        self.__state = 1
Exemplo n.º 5
0
def init():
    print 'LOGGER - INIT'

    # Build a path to the target log output file
    log_name = bf2.gameLogic.getModDir() + '/logs/' + '/bf2_game_log.txt'
    print 'Creating log file: ', log_name

    # Open the log file in line-buffered append mode
    global log_file
    try:
        log_file = open(log_name, 'a', 1)
    except IOError:
        print 'Unable to open log file: ', log_name
        return

    # Log the change in server status
    timestamp = datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
    log('SS', 'start', timestamp)

    # Register the pre-game callbacks
    host.registerHandler('PlayerConnect', on_connect, 1)
    host.registerHandler('PlayerDisconnect', on_disconnect, 1)
    host.registerHandler('Reset', on_reset, 1)

    # Register the game status callback
    host.registerGameStatusHandler(on_game_status)
Exemplo n.º 6
0
def init():
    global G_QUERY_MANAGER

    G_QUERY_MANAGER = QueryManager()
    G_QUERY_MANAGER.setupDefaultQueries()

    host.registerGameStatusHandler(onGameStatusChanged)
def enable():
	global fileName
	global logfile
	global startTime

	if logfile and not logfile.closed:
		print "Fragalyzer logging already enabled"
		return 
		
	host.registerGameStatusHandler(onGameStatusChanged)
	
	currentDate = datetime.datetime.today()
	dateString = ""
	dateString = time.strftime("%y%m%d_%H%M", currentDate.timetuple())

	if dateString != "":
		fileName = bf2.gameLogic.getModDir() + "/Logs/" + bf2.gameLogic.getMapName() + "_" + dateString + "_faLog.txt"
	else:
		fileName = bf2.gameLogic.getModDir() + "/Logs/" + bf2.gameLogic.getMapName() + "_faLog.txt"
		
	fileName = fileName.replace('/', '\\')
	
	print "log file: ", fileName

	try:
		logfile = file (fileName, 'w')
	except Exception:
		if g_debug: print "Couldnt open fragalyzer logfile: ", fileName
		return
	
	startTime = int(date())
	timeString = str(startTime)
	startDate = time.strftime("%Y.%m.%d,%H:%M", currentDate.timetuple())
	logfile.write("INIT LevelName=" + bf2.gameLogic.getMapName() + " StartTime=" + timeString + " StartDate=" + startDate + " Filename=" + fileName + "\n")
		
	logfile.flush()


	# register events
	host.registerHandler('PlayerKilled', onPlayerKilled)
	host.registerHandler('PlayerDeath', onPlayerDeath)
	host.registerHandler('EnterVehicle', onEnterVehicle)
	host.registerHandler('ExitVehicle', onExitVehicle)
	host.registerHandler('PickupKit', onPickupKit)
	host.registerHandler('DropKit', onDropKit)
	host.registerHandler('ControlPointChangedOwner', onCPStatusChange)
	host.registerHandler('PlayerScore', onPlayerScore)
	host.registerHandler('PlayerSpawn', onPlayerSpawn)

	host.registerHandler('PlayerConnect', onPlayerConnect, 1)

	#host.registerHandler('DeployGrapplingHook', onDeployGrapplingHook)
	#host.registerHandler('DeployZipLine', onDeployZipLine)
	#host.registerHandler('DeployTactical', onDeployTactical)
	
	# Connect already connected players if reinitializing
	for p in bf2.playerManager.getPlayers():
		onPlayerConnect(p)
	
	print "Fragalyzer logging enabled."
Exemplo n.º 8
0
def init():
    host.registerHandler('PlayerConnect', onPlayerConnect, 1)
    host.registerHandler('PlayerDisconnect', onPlayerDisconnect, 1)
    host.registerHandler('Reset', onReset, 1)

    host.registerGameStatusHandler(onGameStatusChanged)

    if g_debug: print "Persistant stats module initialized."
Exemplo n.º 9
0
def init():
	host.registerHandler('PlayerConnect', onPlayerConnect, 1)
	host.registerHandler('PlayerDisconnect', onPlayerDisconnect, 1)
	host.registerHandler('Reset', onReset, 1)

	host.registerGameStatusHandler(onGameStatusChanged)
	
	print "Persistant stats module initialized."
Exemplo n.º 10
0
def dconStatsinit():
    host.registerHandler("PlayerConnect", dconOnPlayerConnect, 1)
    host.registerHandler("PlayerDisconnect", onPlayerDisconnect, 1)
    host.registerHandler("Reset", onReset, 1)

    host.registerGameStatusHandler(dconOnGameStatusChanged)

    if g_debug:
        print "dcon stats module initialized."
Exemplo n.º 11
0
def init():
    # Events
    host.registerHandler('PlayerConnect', onPlayerConnect, 1)
    host.registerGameStatusHandler(onGameStatusChanged)

    # Connect already connected players if reinitializing
    for p in bf2.playerManager.getPlayers():
        onPlayerConnect(p)

    if g_debug: print "unlocks.py[16]: Unlock module initialized"
Exemplo n.º 12
0
def init():
	# Events
	host.registerHandler('PlayerConnect', onPlayerConnect, 1)
	host.registerGameStatusHandler(onGameStatusChanged)
	
	# Connect already connected players if reinitializing
	for p in bf2.playerManager.getPlayers():
		onPlayerConnect(p)

	if g_debug: print "unlocks.py[16]: Unlock module initialized"
Exemplo n.º 13
0
def init():
	global OLDSCHOOL_LEVEL, PUNISH_METHOD, ANTICOMMANDER
	if OLDSCHOOL_LEVEL != 0:
		if ANTICOMMANDER == 1: host.registerHandler('ChangedCommander', onCommander, 1)
		if PUNISH_METHOD == 2: host.registerHandler('PlayerKilled', onPlayerKilled, 1)
		if PUNISH_METHOD == 0 or PUNISH_METHOD == 1 and OLDSCHOOL_LEVEL != 3: host.registerHandler('PlayerChangeWeapon', onPlayerChangeWeapon, 1)
		host.registerHandler('RemoteCommand', onRemoteCommand, 1)
		host.registerGameStatusHandler(onGameStatusChange)
		host.rcon_invoke('echo "bf2_oldschool.py by MisiekBest loaded"')
	else:
		host.rcon_invoke('echo "bf2_oldschool.py by MisiekBest loaded, script DISABLED by config!"')
Exemplo n.º 14
0
def init():

    # set limits for how many repair HPs etc are needed to get a callback
    bf2.gameLogic.setHealPointLimit(HEAL_POINT_LIMIT)
    bf2.gameLogic.setRepairPointLimit(REPAIR_POINT_LIMIT)
    bf2.gameLogic.setGiveAmmoPointLimit(GIVEAMMO_POINT_LIMIT)
    bf2.gameLogic.setTeamDamagePointLimit(TEAMDAMAGE_POINT_LIMIT)
    bf2.gameLogic.setTeamVehicleDamagePointLimit(TEAMVEHICLEDAMAGE_POINT_LIMIT)
    
    host.registerGameStatusHandler(onGameStatusChanged)
    
    if g_debug: print "scoring common init"
Exemplo n.º 15
0
def init():
    # events hook
    host.registerGameStatusHandler(onGameStatusChanged)
    if host.sgl_getIsAIGame() == 1:
        host.sh_setEnableCommander(1)
    else:
        host.sh_setEnableCommander(1)

    host.registerHandler("TimeLimitReached", onTimeLimitReached, 1)

    if g_debug:
        print "gpm_cq.py initialized"
Exemplo n.º 16
0
def init():
	# events hook
	try:
		host.registerGameStatusHandler(onGameStatusChanged)
		if host.sgl_getIsAIGame() == 1:
			host.sh_setEnableCommander(0)
		else:
			host.sh_setEnableCommander(1)

		if g_debug: print "gpm_sl.py initialized"
	except Error, e:
		print "init faield "+ str(e)
Exemplo n.º 17
0
    def init(self):
        if 0 == self._state:
            #host.registerHandler( 'EnterVehicle', self.onEnterVehicle, 1 )
            #host.registerHandler( 'PlayerScore', self.onScore, 1 )
            host.registerHandler('PlayerDeath', self.onDeath, 1)
            if dev == True:
                host.registerHandler('ChatMessage', self.onChat, 1)
            #host.registerHandler( 'PlayerSpawn', self.onPlayerSpawn, 1)
            #host.registerHandler( 'PlayerConnect', self.onPlayerConnect, 1)
            #host.registerHandler( 'PlayerDisconnect', self.onPlayerDisconnect, 1)
            host.registerGameStatusHandler(self.onGameStatusChanged)
# Update to the running state
        self._state = 1
Exemplo n.º 18
0
    def init( self ):
        if 0 == self._state:
            #host.registerHandler( 'EnterVehicle', self.onEnterVehicle, 1 )
            #host.registerHandler( 'PlayerScore', self.onScore, 1 )
            host.registerHandler( 'PlayerDeath', self.onDeath, 1 )
            if dev == True:
                host.registerHandler( 'ChatMessage', self.onChat, 1 )
            #host.registerHandler( 'PlayerSpawn', self.onPlayerSpawn, 1)
            #host.registerHandler( 'PlayerConnect', self.onPlayerConnect, 1)
            #host.registerHandler( 'PlayerDisconnect', self.onPlayerDisconnect, 1)
            host.registerGameStatusHandler(self.onGameStatusChanged) 
		# Update to the running state
        self._state = 1
Exemplo n.º 19
0
def init():
    # Events
    host.registerHandler('PlayerConnect', onPlayerConnect, 1)
    host.registerHandler('PlayerDisconnect', onPlayerDisconnect, 1)
    host.registerHandler('PlayerStatsResponse', onStatsResponse, 1)
    host.registerHandler('PlayerAwardsResponse', onAwardsResponse, 1)
    host.registerGameStatusHandler(onGameStatusChanged)

    if g_debug: print "medals.py[142]: Medal awarding module initialized"

    global globalKeyString
    globalKeyString = createGlobalKeyString(globalKeysNeeded)
    if g_debug: print "medals.py[146]: Global key string: ", globalKeyString
Exemplo n.º 20
0
def init():
    # events hook
    global g_plugin
    host.registerGameStatusHandler(onGameStatusChanged)
    if host.sgl_getIsAIGame() == 1:
        host.sh_setEnableCommander(1)
    else:
        host.sh_setEnableCommander(1)
        
    host.registerHandler('TimeLimitReached', onTimeLimitReached, 1)
    
    if g_debug: print "gpm_cq.py initialized"
    g_plugin = game.gameplayPlugin.pluginsystem()
Exemplo n.º 21
0
def init():
    game.players.init()
    # set limits for how many repair HPs etc are needed to get a callback
    bf2.gameLogic.setHealPointLimit(HEAL_POINT_LIMIT)
    bf2.gameLogic.setRepairPointLimit(REPAIR_POINT_LIMIT)
    bf2.gameLogic.setGiveAmmoPointLimit(GIVEAMMO_POINT_LIMIT)
    bf2.gameLogic.setTeamDamagePointLimit(TEAMDAMAGE_POINT_LIMIT)
    bf2.gameLogic.setTeamVehicleDamagePointLimit(TEAMVEHICLEDAMAGE_POINT_LIMIT)

    host.registerGameStatusHandler(onGameStatusChanged)

    if bf2.g_debug:
        print "scoring common init"
Exemplo n.º 22
0
def init():
    # Events

    #if bf2.serverSettings.getUseGlobalRank():
    host.registerHandler('PlayerConnect', onPlayerConnect, 1)
    host.registerHandler('PlayerStatsResponse', onStatsResponse, 1)

    host.registerGameStatusHandler(onGameStatusChanged)

    # Connect already connected players if reinitializing
    for p in bf2.playerManager.getPlayers():
        onPlayerConnect(p)

    if g_debug: print "rank.py[24]: Rank module initialized"
Exemplo n.º 23
0
def init():
	# Events

	if bf2.serverSettings.getUseGlobalRank():
	 	host.registerHandler('PlayerConnect', onPlayerConnect, 1)
		host.registerHandler('PlayerStatsResponse', onStatsResponse, 1)

	host.registerGameStatusHandler(onGameStatusChanged)
	
	# Connect already connected players if reinitializing
	for p in bf2.playerManager.getPlayers():
		onPlayerConnect(p)

	if g_debug: print "Rank module initialized"
Exemplo n.º 24
0
def init():
	# Events
	host.registerHandler('PlayerConnect', onPlayerConnect, 1)
	host.registerHandler('PlayerDisconnect', onPlayerDisconnect, 1)
	host.registerHandler('PlayerStatsResponse', onStatsResponse, 1)
	host.registerHandler('PlayerAwardsResponse', onAwardsResponse, 1)
	host.registerGameStatusHandler(onGameStatusChanged)


	if g_debug: print "medals.py[142]: Medal awarding module initialized"

	global globalKeyString
	globalKeyString = createGlobalKeyString(globalKeysNeeded)
	if g_debug: print "medals.py[146]: Global key string: ", globalKeyString
Exemplo n.º 25
0
	def init( self ):
		"""Provides default initialisation."""
		self.__config = self.mm.getModuleConfig( configDefaults )

		# Register our game handlers
		if 0 == self.__state:
			host.registerHandler( 'PlayerConnect', self.onPlayerConnect, 1 )
			host.registerHandler( 'PlayerDeath', self.onPlayerDeath, 1 )
			host.registerHandler( 'PlayerChangeTeams', self.onPlayerChangeTeams, 1 )

		# Register your game handlers and provide any
		# other dynamic initialisation here
		host.registerGameStatusHandler( self.onGameStatusChanged )

		self.__state = 1
Exemplo n.º 26
0
    def init(self):
        """Provides default initialisation."""

        # Load the configuration
        self.__config = self.mm.getModuleConfig(configDefaults)

        # Register your game handlers and provide any
        # other dynamic initialisation here

        if 0 == self.__state:
            # Register your host handlers here
            host.registerGameStatusHandler(self.onGameStatusChanged)

        # Update to the running state
        self.__state = 1
Exemplo n.º 27
0
def init():
    # Events
    # Added by Chump - for bf2statistics stats
    #	if not host.ss_getParam('ranked'): return

    host.registerHandler('PlayerConnect', onPlayerConnect, 1)
    host.registerHandler('PlayerDisconnect', onPlayerDisconnect, 1)
    host.registerHandler('PlayerStatsResponse', onStatsResponse, 1)
    host.registerHandler('PlayerAwardsResponse', onAwardsResponse, 1)
    host.registerGameStatusHandler(onGameStatusChanged)

    print "Medal awarding module initialized"

    global globalKeyString
    globalKeyString = createGlobalKeyString(globalKeysNeeded)
    print "Global key string: ", globalKeyString
Exemplo n.º 28
0
def init():
    # Events
    # Added by Chump - for bf2statistics stats
    # 	if not host.ss_getParam('ranked'): return

    host.registerHandler("PlayerConnect", onPlayerConnect, 1)
    host.registerHandler("PlayerDisconnect", onPlayerDisconnect, 1)
    host.registerHandler("PlayerStatsResponse", onStatsResponse, 1)
    host.registerHandler("PlayerAwardsResponse", onAwardsResponse, 1)
    host.registerGameStatusHandler(onGameStatusChanged)

    print "Medal awarding module initialized"

    global globalKeyString
    globalKeyString = createGlobalKeyString(globalKeysNeeded)
    print "Global key string: ", globalKeyString
Exemplo n.º 29
0
def init():
    # If stats are disabled, quit
    if not stats_enable:
        print "Medal awarding module disabled by config"
        return

    # Events
    host.registerHandler('PlayerConnect', onPlayerConnect, 1)
    host.registerHandler('PlayerDisconnect', onPlayerDisconnect, 1)
    host.registerHandler('PlayerStatsResponse', onStatsResponse, 1)
    host.registerHandler('PlayerAwardsResponse', onAwardsResponse, 1)
    host.registerGameStatusHandler(onGameStatusChanged)

    print "Medal awarding module initialized"
    print "Using Xpack Medals: ", str(allow_xpack_medals)
    print "Global key string: ", globalKeyString
Exemplo n.º 30
0
    def init(self):
        self.__config = self.mm.getModuleConfig(configDefaults)

        self.kickInterval = self.__config['kickInterval']
        self.msgInterval = self.__config['msgInterval']
        self.kickDelay = self.__config['kickDelay']
        self.prefixMsg = self.__config['prefixMsg']
        self.warningMsg = self.__config['warningMsg']
        self.enable_squadless_kick = self.__config['enable_squadless_kick']
        self.isPublicWarning = self.__config['isPublicWarning']

        if self.enable_squadless_kick == 1 and 0 == self.__state:
            host.registerHandler('PlayerSpawn', self.onPlayerSpawn)
            host.registerGameStatusHandler(self.onGameStatusChanged)

        self.__state = 1
Exemplo n.º 31
0
def init():
    host.registerHandler('PlayerConnect', onPlayerConnect, 1)
    host.registerHandler('PlayerDisconnect', onPlayerDisconnect, 1)
    host.registerHandler('Reset', onReset, 1)

    host.registerGameStatusHandler(onGameStatusChanged)

    #if host.ss_getParam('ranked'):
    try:
        import bf2.stats.medal_data
    except ImportError:
        print "stats.py[45]: Medal awarding_data module not found. %s" % ImportError
    else:
        print "stats.py[47]: Medal awarding data module found."
        bf2.stats.medal_data.update_rank_criteria()

    if g_debug: print "stats.py[50]: Persistant stats module initialized."
Exemplo n.º 32
0
 def init():
 
    if g_debug or xlr_debug: print 'IDLEKICK: initializing IdleKick script'
    # Force at least 20 seconds between idle checks:
    if interval < 10: interval = 10
    # Print debug message if autokick is disabled:
    if autokick != 1:
       if g_debug or xlr_debug: print 'IDLEKICK: Idle autokick not enabled'
    
    # Autokick is enabled, so hook it up:
    else:
       if g_debug or xlr_debug: print 'IDLEKICK: Enabling kick for being idle. Max. checkfails = %s.' % (warnings)
 
       # Register 'PlayerConnect' callback:
       host.registerHandler('PlayerConnect', onPlayerConnect, 1)
       host.registerHandler('PlayerSpawn', onPlayerSpawn, 1)
       host.registerGameStatusHandler(onGameStatusChanged)
Exemplo n.º 33
0
def init():
    # events hook
    global g_plugin
    host.registerGameStatusHandler(onGameStatusChanged)
    if host.sgl_getIsAIGame() == 1:
        host.sh_setEnableCommander(1)
    else:
        host.sh_setEnableCommander(1)
        
    host.registerHandler('TimeLimitReached', onTimeLimitReached, 1)
    
    # Reset ticket loss values
    game.gameplayPlugin.setDefaultTicketLossPerMin(1, game.gameplayPlugin.DEFAULT_TICKET_LOSS_PER_MIN)
    game.gameplayPlugin.setDefaultTicketLossPerMin(2, game.gameplayPlugin.DEFAULT_TICKET_LOSS_PER_MIN)
    
    if g_debug: print "gpm_cq.py initialized"
    g_plugin = game.gameplayPlugin.pluginsystem()
Exemplo n.º 34
0
def init():
	host.registerHandler('PlayerConnect', onPlayerConnect, 1)
	host.registerHandler('PlayerDisconnect', onPlayerDisconnect, 1)
	host.registerHandler('Reset', onReset, 1)

	host.registerGameStatusHandler(onGameStatusChanged)
	
	#if host.ss_getParam('ranked'):
	try:
		import bf2.stats.medal_data
	except ImportError:
		print "stats.py[45]: Medal awarding_data module not found. %s" % ImportError
	else:
		print "stats.py[47]: Medal awarding data module found."
		bf2.stats.medal_data.update_rank_criteria()	

	if g_debug: print "stats.py[50]: Persistant stats module initialized."
Exemplo n.º 35
0
def init():
    global OLDSCHOOL_LEVEL, PUNISH_METHOD, ANTICOMMANDER
    if (OLDSCHOOL_LEVEL != 0):
        if (ANTICOMMANDER == 1):
            host.registerHandler('ChangedCommander', onCommander, 1)
        if (PUNISH_METHOD == 2):
            host.registerHandler('PlayerKilled', onPlayerKilled, 1)
        if (PUNISH_METHOD == 0
                or (PUNISH_METHOD == 1 and OLDSCHOOL_LEVEL != 3)):
            host.registerHandler('PlayerChangeWeapon', onPlayerChangeWeapon, 1)
        host.registerHandler('RemoteCommand', onRemoteCommand, 1)
        host.registerGameStatusHandler(onGameStatusChange)
        host.rcon_invoke('echo "bf2_oldschool.py by MisiekBest loaded"')
    else:
        host.rcon_invoke(
            'echo "bf2_oldschool.py by MisiekBest loaded, script DISABLED by config!"'
        )
Exemplo n.º 36
0
	def init( self ):
		"""Provides default initialisation."""
		self.__config = self.mm.getModuleConfig( configDefaults )
		self.hasPendingTks = {}
		self.updateTimer = None

		# Register our base handlers
		host.registerGameStatusHandler( self.onGameStatusChanged )

		if 0 == self.__state:
			host.registerHandler( 'PlayerConnect', self.onPlayerConnect, 1 )
			host.registerHandler( 'PlayerKilled', self.onPlayerKilled )
			host.registerHandler( 'ClientCommand', self.onClientCommand )

		# Connect already connected players if reinitializing
		for p in bf2.playerManager.getPlayers():
			self.onPlayerConnect( p )

		self.checkEnable()
		self.__state = 1
    def init(self):
        """Provides default initialisation."""
        self.__config = self.mm.getModuleConfig(configDefaults)
        self.hasPendingTks = {}
        self.updateTimer = None

        # Register our base handlers
        host.registerGameStatusHandler(self.onGameStatusChanged)

        if 0 == self.__state:
            host.registerHandler('PlayerConnect', self.onPlayerConnect, 1)
            host.registerHandler('PlayerKilled', self.onPlayerKilled)
            host.registerHandler('ClientCommand', self.onClientCommand)

        # Connect already connected players if reinitializing
        for p in bf2.playerManager.getPlayers():
            self.onPlayerConnect(p)

        self.checkEnable()
        self.__state = 1
Exemplo n.º 38
0
def init():
	global g_playing, g_timer, state, g_need_choose_map, g_ml_game_start_time

#	if g_debug: 
	print 'initializing Drill\'s AutoMap'

	g_playing = False
	g_need_choose_map = True
	g_ml_game_start_time = None
	
	g_timer = bf2.Timer(onTimer, g_timer_update_rate, 1)
	g_timer.setRecurring(g_timer_update_rate)
	
	InitMapsRun()

	random.seed()
	host.registerGameStatusHandler(onGameStatusChanged)
	
	init_mapchanal()
	
	state = RUN
Exemplo n.º 39
0
	def init( self ):
		"""Provides default initialisation."""

		# Load the configuration
		self.__config = self.mm.getModuleConfig( configDefaults )
		self.__banFileName = self.mm.configPath() + '/' + self.__config['banFilename']

		# Load the bans
		self.loadBans()

		# Register our base handlers
		host.registerGameStatusHandler( self.onGameStatusChanged )

		# Register our rcon command handlers
		self.mm.registerRconCmdHandler( 'bm', { 'method': self.cmdExec, 'subcmds': self.__cmds, 'level': 1 } )

		if 0 == self.__state:
			host.registerHandler( 'PlayerDisconnect', self.onPlayerDisconnect, 1 )

		# Register your game handlers and provide any
		# other dynamic initialisation here

		# Update to the running state
		self.__state = 1
Exemplo n.º 40
0
def init():
    decho('dc_pop_log: initializing DontCamp.com Population Logger', 2)
    host.registerHandler('PlayerConnect', onPlayerConnect, 1)
    host.registerHandler('PlayerDisconnect', onPlayerDisconnect, 1)
    host.registerGameStatusHandler(onStatusChange)
Exemplo n.º 41
0
	def init( self ):
		"""Provides default initialisation."""

		# Load the configuration
		self.__config = self.mm.getModuleConfig( configDefaults )
		self.__playing = 0
		self.__banWords = {}
		self.__banPatterns = {}
		self.__kickPatterns = {}
		self.__kickWords = {}

		# Register our base handlers
		if 0 == self.__state:
			self.mm.debug( 2, "Setting Connect and Chat handlers" )
			host.registerHandler( 'PlayerConnect', self.onPlayerConnect, 1 )
			host.registerHandler( 'ChatMessage', self.onChatMessage, 1 )
			self.mm.debug( 2, "Handlers set" )
		else:
			self.mm.debug( 2, "Handlers NOT set" )

		host.registerGameStatusHandler( self.onGameStatusChanged )

		# Register our rcon command handlers
		self.mm.registerRconCmdHandler( 'kicker', { 'method': self.cmdExec, 'subcmds': self.__cmds, 'level': 1 } )

		# Apply ranked server restrictions
		if host.ss_getParam('ranked'):
			if 0 != self.__config['minPing']:
				self.__config['minPing'] = 0
				self.mm.warn( "Min ping is restricted on ranked servers setting to %d" % self.__config['minPing'] )

			if self.__config['maxPing'] and self.__config['maxPing'] < 160:
				self.__config['maxPing'] = 160
				self.mm.warn( "Max ping is restricted on ranked servers setting to %d" % self.__config['maxPing'] )

		# set up our times
		self.__checkTimer = bf2.Timer( self.checkPlayers, self.__config['initDelay'], 1 )
		self.__checkTimer.setRecurring( self.__config['sampleRate'] )

		# ban words
		idx = 0
		for word in self.__config['banWords']:
			self.__banWords[word] = idx
			idx += 1

		# ban patterns
		idx = 0
		for pattern in self.__config['banPatterns']:
			try:
				self.__banPatterns[pattern] = [ re.compile( pattern ), idx ]
				idx += 1
			except:
				self.mm.error( "Invalid bad pattern '%s'" % pattern )

		# kick words
		idx = 0
		for word in self.__config['kickWords']:
			self.__kickWords[word] = idx
			idx += 1

		# kick patterns
		idx = 0
		for pattern in self.__config['kickPatterns']:
			try:
				self.__kickPatterns[pattern] = [ re.compile( pattern ), idx ]
				idx += 1
			except:
				self.mm.error( "Invalid kick pattern '%s'" % pattern )

		# add already connected players
		for player in bf2.playerManager.getPlayers():
			player.mmKickerInfo = KickerInfo()

		self.__state = 1
Exemplo n.º 42
0
def init():
	decho('dc_pop_log: initializing DontCamp.com Population Logger', 2)
	host.registerHandler('PlayerConnect', onPlayerConnect, 1)
	host.registerHandler('PlayerDisconnect', onPlayerDisconnect, 1)
	host.registerGameStatusHandler(onStatusChange)
Exemplo n.º 43
0
def init():
	print "Snapshot module initialized"

# Added by Chump - for bf2statistics stats
	host.registerGameStatusHandler(onChangeGameStatus)
Exemplo n.º 44
0
	def __init__( self, debuglog ):
		"""Create a module manager, loading the configuration and any requested modules."""
		# default init

		self.__bf2String = 'Battlefield 2'
		self.__bf2142String = 'Battlefield 2142'
		self.__bfheroesString = 'Battlefield Heroes'
		self.__bfp4fString = 'Battlefield Play 4 Free'
		self.__bf2Id = 'bf2'
		self.__bf2142Id = 'bf2142'
		self.__bfheroesId = 'bfheroes'
		self.__bfp4fId = 'bfp4f'
		self.__gameId = self.__bf2Id
		self.__gameString = self.__bf2String
		self.__gameName = self.__bf2Id
		self.__state = 0
		self.__logger = None
		self.__modules = {}
		self.__updateRequestors = []
		self.__configFull = { __name__: {} }
		self.__playCount = 0
		self.__pauseStart = 0
		self.__matchTimeLost = 0
		self.__timeLimit = 0
		self.lastGameStatus = bf2.GameStatus.PreGame
		self.currentGameStatus = bf2.GameStatus.PreGame
		self.gamePlaying = False
		self.roundStarted = False
		self.startTimeUTC = int( time.time() )
		self.startTimeWall = int( host.timer_getWallTime() )

		# Load our config default and set to local vars
		for var in configDefaults:
			val = configDefaults[var]
			self.__configFull[__name__][var] = val
			self.__setattr__( var, val )

		mm_utils.init( self )

		# Determine where to load the config from
		self.__setConfigFile();

		# parse the configuration file
		self.__parseConfig()

		# Enable debug if required
		if self.debugEnable:
			# close the startup log
			# Note: we dont always close this as that would cause issues
			if debuglog:
				debuglog.close()
			# open the new one ( settings may have changed
			sys.stdout = sys.stderr = DebugLogger( self.debugFile, self.logAppend, self.logAutoFlush )

		# add the module base to the path
		sys.path.append( 'admin/' + self.moduleBase )
		sys.path.append( 'admin/' + self.moduleBase + '/libs' )

		# create the logger
		self.__initLogger()

		self.info( 'Creating Multiplay, ModManager v%s for %s (www.multiplay.co.uk)' % ( __version__, self.__gameString ) )

		# We listen to state changes so we can tell others what
		# the current state is if they are dynamically loaded
		host.registerGameStatusHandler( self.onGameStatusChanged )

		# create the rcon
		self.__initRcon()

		# Initialise the ban system
		self.__initBanManager()

		# Register our rcon command handlers
		# Our internal commands
		self.__cmds = {
			'printRunningConfig': { 'method': self.cmdPrintRunningConfig, 'aliases': [ 'print' ], 'level': 80 },
			'saveConfig': { 'method': self.cmdSaveConfig, 'aliases': [ 'save' ], 'level': 90 },
			'loadModule': { 'method': self.cmdLoadModule, 'args': '<module_name>', 'aliases': [ 'load' ], 'level': 90 },
			'listModules': { 'method': self.cmdListModules, 'aliases': [ 'list' ], 'level': 70 },
			'shutdownModule': { 'method': self.cmdShutdownModule, 'args': '<module_name>', 'aliases': [ 'shutdown' ], 'level': 90 },
			'startModule': { 'method': self.cmdStartModule, 'args': '<module_name>', 'aliases': [ 'start' ], 'level': 90 },
			'reloadModule': { 'method': self.cmdReloadModule, 'args': '<module_name>', 'aliases': [ 'reload' ], 'level': 90 },
			'setParam': { 'method': self.cmdSetParam, 'args': '<module_name> <param> <value>', 'aliases': [ 'set' ], 'level': 90 },
		}

		# load the modules
		self.__loadModules();
Exemplo n.º 45
0
def init():
	if enableClanManager == 1:
		print "Clan Manager module initialized (%d)" % mode
		host.registerHandler('PlayerConnect', onPlayerConnect, 1)
		host.registerGameStatusHandler(onGameStatusChanged)
Exemplo n.º 46
0
def init():
	if g_debug: print "snapshot.py[53]: Snapshot module initialized"
	host.registerGameStatusHandler(onChangeGameStatus)
Exemplo n.º 47
0
def init():
    host.registerGameStatusHandler(gameStatus)
Exemplo n.º 48
0
def init():
	if enableClanManager == 1:
		print "Clan Manager module initialized (%d)" % mode
		host.registerHandler('PlayerConnect', onPlayerConnect, 1)
		host.registerGameStatusHandler(onGameStatusChanged)
Exemplo n.º 49
0
def init():
    host.registerGameStatusHandler(onGameStatusChanged)
Exemplo n.º 50
0
def init():
	if g_debug: print "snapshot.py[53]: Snapshot module initialized"
	host.registerGameStatusHandler(onChangeGameStatus)
Exemplo n.º 51
0
def init():
    host.registerGameStatusHandler(onGameStatusChanged)
Exemplo n.º 52
0
def init():
    print "Snapshot module initialized"

    # Added by Chump - for bf2statistics stats
    host.registerGameStatusHandler(onChangeGameStatus)
Exemplo n.º 53
0
    def init(self):
        """Provides default initialisation."""

        # Load the configuration
        self.__config = self.mm.getModuleConfig(configDefaults)
        self.__playing = 0
        self.__banWords = {}
        self.__banPatterns = {}
        self.__kickPatterns = {}
        self.__kickWords = {}

        # Register our base handlers
        if 0 == self.__state:
            self.mm.debug(2, "Setting Connect and Chat handlers")
            host.registerHandler('PlayerConnect', self.onPlayerConnect, 1)
            host.registerHandler('ChatMessage', self.onChatMessage, 1)
            self.mm.debug(2, "Handlers set")
        else:
            self.mm.debug(2, "Handlers NOT set")

        host.registerGameStatusHandler(self.onGameStatusChanged)

        # Register our rcon command handlers
        self.mm.registerRconCmdHandler('kicker', {
            'method': self.cmdExec,
            'subcmds': self.__cmds,
            'level': 1
        })

        # Apply ranked server restrictions
        if host.ss_getParam('ranked'):
            if 0 != self.__config['minPing']:
                self.__config['minPing'] = 0
                self.mm.warn(
                    "Min ping is restricted on ranked servers setting to %d" %
                    self.__config['minPing'])

            if self.__config['maxPing'] and self.__config['maxPing'] < 160:
                self.__config['maxPing'] = 160
                self.mm.warn(
                    "Max ping is restricted on ranked servers setting to %d" %
                    self.__config['maxPing'])

        # set up our times
        self.__checkTimer = bf2.Timer(self.checkPlayers,
                                      self.__config['initDelay'], 1)
        self.__checkTimer.setRecurring(self.__config['sampleRate'])

        # ban words
        idx = 0
        for word in self.__config['banWords']:
            self.__banWords[word] = idx
            idx += 1

        # ban patterns
        idx = 0
        for pattern in self.__config['banPatterns']:
            try:
                self.__banPatterns[pattern] = [re.compile(pattern), idx]
                idx += 1
            except:
                self.mm.error("Invalid bad pattern '%s'" % pattern)

        # kick words
        idx = 0
        for word in self.__config['kickWords']:
            self.__kickWords[word] = idx
            idx += 1

        # kick patterns
        idx = 0
        for pattern in self.__config['kickPatterns']:
            try:
                self.__kickPatterns[pattern] = [re.compile(pattern), idx]
                idx += 1
            except:
                self.mm.error("Invalid kick pattern '%s'" % pattern)

        # add already connected players
        for player in bf2.playerManager.getPlayers():
            player.mmKickerInfo = KickerInfo()

        self.__state = 1