def debugFile(msg): try: # fileName = host.sgl_getModDirectory() + C.spawnerLogPath logFile = open(host.sgl_getModDirectory() + C.LOGFILENAME, 'a') logFile.write(str(msg) + '\n') logFile.close() except: pass
def debugFile(msg): try: fileName = host.sgl_getModDirectory() + C.spawnerLogPath logFile = open(fileName, "a") logTime = time_string_now() logFile.write("t: " + str(logTime) + " " + str(msg) + "\n") logFile.close() except: pass
def __setConfigFile( self ): """Determines where our config file is.""" try: # Try 2142 way self.__configPath = host.sgl_getOverlayDirectory() try: test = bf2.stats.constants.TYPE_BFHEROES self.__gameString = self.__bfheroesString self.__gameId = self.__bfheroesId except: try: test = bf2.stats.constants.ARMY_US self.__gameString = self.__bfp4fString self.__gameId = self.__bfp4fId except: self.__gameString = self.__bf2142String self.__gameId = self.__bf2142Id except: # Failed 2142 so fall back to determining from the config self.__gameString = self.__bf2String self.__gameId = self.__bf2Id configFileParts = host.rcon_invoke( 'sv.configFile' ).replace( '\\', '/' ).split( '/' ); del configFileParts[len( configFileParts ) - 1] self.__configPath = "/".join( configFileParts ) if self.__configPath.startswith( '@HOME@' ): # since we have no access to the environment and cant # do any directory listings atm we have to just guess self.warn( "Guessing '@HOME@' = '%s'" % self.homeGuess ) self.__configPath = "%s%s" % ( self.homeGuess, self.__configPath[5:] ) filename = "%s/%s.con" % ( self.__configPath, __name__ ) # lets check try: check = open( filename, 'r' ) except: # nope no good so lets check in the standard place self.__configPath = "%s/settings" % host.sgl_getModDirectory().replace( '\\', '/' ) filename = "%s/%s.con" % ( self.__configPath, __name__ ) try: check = open( filename, 'r' ) except: self.error( "Failed to determine location of '%s.con'" % __name__ ) else: self.__configFile = filename self.warn( "Using config file '%s'" % filename ) check.close() else: check.close() self.__configFile = filename
def getSnapShot(): print "snapshot.py: Assembling snapshot" #snapShot = "\\" global map_start snapShot = snapshot_prefix + "\\" + bf2.gameLogic.getMapName() + "\\" snapShot += "mapstart\\" + str(map_start) + "\\mapend\\" + str(time()) + "\\" snapShot += "win\\" + str(bf2.gameLogic.getWinner()) + "\\" statsMap = getStatsMap() # ---------------------------------------------------------------------------- # omero 2006-04-10 # ---------------------------------------------------------------------------- # this will be used for detecting which mod is running and # set standardKeys['v'] accordingly # running_mod = str(host.sgl_getModDirectory()) if ( running_mod == "mods/bf2142" ): v_value = "bf2142" else: v_value = "!!!ERROR!!! fixme" if g_debug: print "snapshot.py: Running MOD: %s" % (str(v_value)) standardKeys = [ ("gm", getGameModeId(bf2.serverSettings.getGameMode())), ("m", getMapId(bf2.serverSettings.getMapName())), ("v", str(v_value)), ("pc", len(statsMap)), ] # only send rwa key if there was a winner winner = bf2.gameLogic.getWinner() if winner != 0: standardKeys += [("rwa", roundArmies[winner])] stdKeyVals = [] for k in standardKeys: stdKeyVals.append ("\\".join((k[0], str(k[1])))) snapShot += "\\".join(stdKeyVals) if g_debug: print "snapshot.py: Snapshot Pre-processing complete: %s" % (str(snapShot)) playerSnapShots = "" if g_debug: print "snapshot.py: Num clients to base snap on: %d" % (len(statsMap)) for sp in statsMap.itervalues(): if g_debug: print "snapshot.py: Processing PID: %s" % (str(sp.profileId)) playerSnapShot = getPlayerSnapshot(sp) playerSnapShots += playerSnapShot snapShot += playerSnapShots # Add EOF marker for validation snapShot += "\\EOF\\1" return snapShot
def debugFile(msg): try: # fileName = host.sgl_getModDirectory() + C.spawnerLogPath logFile = open( host.sgl_getModDirectory() + '/python/game/objmodv2/' + FILENAME_DEBUG, 'a') logFile.write(str(msg) + '\n') logFile.close() except: pass
def onGameStatusChanged(status): if status == bf2.GameStatus.EndGame: now = datetime.now() path = host.sgl_getModDirectory() + record_folder + str(bf2.gameLogic.getMapName()) + '_' + str(now.day) + str(now.hour) + str(now.minute) + record_extension try: f = open(path,'w+') json = '[' # Available values: #('deaths','kills','TKs','score','skillScore','rplScore','cmdScore','fracScore','rank','firstPlace','secondPlace','thirdPlace', # 'bulletsFired','bulletsGivingDamage','bulletsFiredAndClear','bulletsGivingDamageAndClear') first = 1 for p in bf2.playerManager.getPlayers(): try: name = p.getName() deaths = str(p.score.__getattr__('deaths')) kills = str(p.score.__getattr__('kills')) wounded = str(p.isManDown()); except Exception, e: name = str(e) kills = 'Invalid' deaths = 'Invalid' wounded = 'Invalid' if first: first = 0 json += '{' else: json += ',{' json += '"name":"' + name + '"' + json_separator json += '"deaths":"' + deaths + '"' + json_separator json += '"wounded":"' + wounded + '"' + json_separator json += '"kills":"' + kills + '"' json += '}' json += ']' f.write(json) f.close() except Exception, e: try: f = open(path,'w+') f.write(str(e)) f.close() except : pass
def rankedstart(): if g_debug: print "Ranked Install module initialized." try: logfile = open('Ranked_mod_install.log', 'w') logfile.write('Ranked mod Installation log started\n') logfile.write('www.uagames.com\n\n') logfile.close() except: print " Logfile Write Permission Error." print " Please Make All Python files Writable, and their directories, As well as the BF2142 Main directory" print " installation halted" xmoddir = host.sgl_getModDirectory() xmod = xmoddir.strip('mods/') #getfile('BF2142StatisticsConfig.py','python/bf2/','__init__.py') #getfile('GameLogic.py','python/bf2/','BF2142StatisticsConfig.py') #getfile('ObjectManager.py','python/bf2/','GameLogic.py') #getfile('PlayerManager.py','python/bf2/','ObjectManager.py') #getfile('Timer.py','python/bf2/','PlayerManager.py') #getfile('TriggerManager.py','python/bf2/','Timer.py') #getfile('constants.py','python/bf2/stats/','__init__.py') #getfile('endofround.py','python/bf2/stats/','constants.py') #getfile('fragalyzer_log.py','python/bf2/stats/','endofround.py') getfile('stats/medal_data.py','python/bf2/','__init__.py') getfile('stats/medals.py','python/bf2/','stats/medal_data.py') #getfile('miniclient.py','python/bf2/stats/','medals.py') #getfile('rank.py','python/bf2/stats/','miniclient.py') getfile('stats/snapshot.py','python/bf2/','stats/medals.py') #getfile('stats.py','python/bf2/stats/','snapshot.py') #getfile('unlocks.py','python/bf2/stats/','stats.py') getfile('Ranked-README.txt','','Ranked00001.tmp') logfile = open('Ranked_mod_install.log', 'a') logfile.write('--end--\n') logfile.close() #####END#####
def rankedstart(): if g_debug: print "Ranked Install module initialized." try: logfile = open('Ranked_mod_install.log', 'w') logfile.write('Ranked mod Installation log started\n') logfile.write('www.uagames.com\n\n') logfile.close() except: print " Logfile Write Permission Error." print " Please Make All Python files Writable, and their directories, As well as the BF2142 Main directory" print " installation halted" xmoddir = host.sgl_getModDirectory() xmod = xmoddir.strip('mods/') #getfile('BF2142StatisticsConfig.py','python/bf2/','__init__.py') #getfile('GameLogic.py','python/bf2/','BF2142StatisticsConfig.py') #getfile('ObjectManager.py','python/bf2/','GameLogic.py') #getfile('PlayerManager.py','python/bf2/','ObjectManager.py') #getfile('Timer.py','python/bf2/','PlayerManager.py') #getfile('TriggerManager.py','python/bf2/','Timer.py') #getfile('constants.py','python/bf2/stats/','__init__.py') #getfile('endofround.py','python/bf2/stats/','constants.py') #getfile('fragalyzer_log.py','python/bf2/stats/','endofround.py') getfile('stats/medal_data.py', 'python/bf2/', '__init__.py') getfile('stats/medals.py', 'python/bf2/', 'stats/medal_data.py') #getfile('miniclient.py','python/bf2/stats/','medals.py') #getfile('rank.py','python/bf2/stats/','miniclient.py') getfile('stats/snapshot.py', 'python/bf2/', 'stats/medals.py') #getfile('stats.py','python/bf2/stats/','snapshot.py') #getfile('unlocks.py','python/bf2/stats/','stats.py') getfile('Ranked-README.txt', '', 'Ranked00001.tmp') logfile = open('Ranked_mod_install.log', 'a') logfile.write('--end--\n') logfile.close() #####END#####
def getModDir(self): return host.sgl_getModDirectory() def getMapName(self): return host.sgl_getMapName()
def getSnapShot(): print "Assembling snapshot" # Added by Chump - for bf2statistics stats #snapShot = "\\" #global PREFIX, map_start global map_start snapShot = snapshot_prefix + '\\' + bf2.gameLogic.getMapName() + '\\' snapShot += 'gameport\\' + str(bf2.serverSettings.getServerConfig('sv.serverPort')) + '\\' snapShot += 'queryport\\' + str(bf2.serverSettings.getServerConfig('sv.gameSpyPort')) + '\\' snapShot += 'mapstart\\' + str(map_start) + '\\mapend\\' + str(time()) + '\\' snapShot += 'win\\' + str(bf2.gameLogic.getWinner()) + '\\' statsMap = getStatsMap() # ---------------------------------------------------------------------------- # omero 2006-04-10 # ---------------------------------------------------------------------------- # this will be used for detecting which mod is running and # set standardKeys['v'] accordingly # defaults to 'bf2' # running_mod = str(host.sgl_getModDirectory()) if ( running_mod.lower() == 'mods/bf2' ): v_value = 'bf2' elif ( running_mod.lower() == 'mods/bf2sp64' ): v_value = 'bf2sp64' elif ( running_mod.lower() == 'mods/xpack' ): v_value = 'xpack' elif ( running_mod.lower() == 'mods/poe2' ): v_value = 'poe2' elif ( running_mod.lower() == 'mods/aix2' ): v_value = 'aix2' else: v_value = 'bf2' if g_debug: print 'Running MOD: %s' % (str(v_value)) standardKeys = [ # Added by Chump - for bf2statistics stats ("gm", getGameModeId(bf2.serverSettings.getGameMode())), ("m", getMapId(bf2.serverSettings.getMapName())), # Added by Chump - for bf2statistics stats ("v", str(v_value)), ("pc", len(statsMap)), ] # only send rwa key if there was a winner winner = bf2.gameLogic.getWinner() if winner != 0: standardKeys += [("rwa", roundArmies[winner])] # get final ticket score if g_debug: print "Army 1 (%s) Score: %s" % (str(roundArmies[1]), str(bf2.gameLogic.getTickets(1))) if g_debug: print "Army 2 (%s) Score: %s" % (str(roundArmies[2]), str(bf2.gameLogic.getTickets(2))) standardKeys += [ ("ra1", str(roundArmies[1])), ("rs1", str(bf2.gameLogic.getTickets(1))), ("ra2", str(roundArmies[2])), ("rs2", str(bf2.gameLogic.getTickets(2))), ] standardKeys += [("rst2", str(bf2.gameLogic.getTickets(2)))] stdKeyVals = [] for k in standardKeys: stdKeyVals.append ("\\".join((k[0], str(k[1])))) snapShot += "\\".join(stdKeyVals) if g_debug: print 'Snapshot Pre-processing complete: %s' % (str(snapShot)) playerSnapShots = "" if g_debug: print 'Num clients to base snap on: %d' % (len(statsMap)) for sp in statsMap.itervalues(): if g_debug: print 'Processing PID: %s' % (str(sp.profileId)) playerSnapShot = getPlayerSnapshot(sp) # Added by Chump - for bf2statistics stats playerSnapShots += playerSnapShot # remove zero vals #zeroAllowedKeys = ('pid', 'a', 'mvns', 'mvks', 'vmns', 'vmks') #transformedSnapShot = "" #i = 0 #while i < len(playerSnapShot): # i += 1 # key = "" # while playerSnapShot[i] != "\\": # key += playerSnapShot[i] # i += 1 # i += 1 # value = "" # while i < len(playerSnapShot) and playerSnapShot[i] != "\\": # value += playerSnapShot[i] # i += 1 # if value != "0" or key[:key.find('_')] in zeroAllowedKeys: # keyVal = "\\" + key + "\\" + value # transformedSnapShot += keyVal #if len(transformedSnapShot) > 0: # playerSnapShots += transformedSnapShot print "Doing Player SNAPSHOTS" snapShot += playerSnapShots # Add EOF marker for validation snapShot += "\\EOF\\1" return snapShot
def getModDir(self): return host.sgl_getModDirectory()
def getSnapShot(): print "Assembling snapshot" global map_start snapShot = snapshot_prefix + '\\' + str( bf2.serverSettings.getServerConfig('sv.serverName')) + '\\' snapShot += 'gameport\\' + str( bf2.serverSettings.getServerConfig('sv.serverPort')) + '\\' snapShot += 'queryport\\' + str( bf2.serverSettings.getServerConfig('sv.gameSpyPort')) + '\\' snapShot += 'mapname\\' + str(bf2.gameLogic.getMapName()) + '\\' snapShot += 'mapid\\' + str(getMapId( bf2.serverSettings.getMapName())) + '\\' snapShot += 'mapstart\\' + str(map_start) + '\\mapend\\' + str( time()) + '\\' snapShot += 'win\\' + str(bf2.gameLogic.getWinner()) + '\\' if g_debug: print 'Finished Pre-Compile SNAPSHOT' statsMap = getStatsMap() # ---------------------------------------------------------------------------- # omero 2006-04-10 # ---------------------------------------------------------------------------- # this will be used for detecting which mod is running and # set standardKeys['v'] accordingly # defaults to 'bf2' # running_mod = str(host.sgl_getModDirectory()) if (running_mod.lower() == 'mods/bf2'): v_value = 'bf2' elif (running_mod.lower() == 'mods/bf2sp64'): v_value = 'bf2sp64' elif (running_mod.lower() == 'mods/xpack'): v_value = 'xpack' elif (running_mod.lower() == 'mods/poe2'): v_value = 'poe2' elif (running_mod.lower() == 'mods/aix2'): v_value = 'aix2' else: v_value = 'bf2' if g_debug: print 'Running MOD: %s' % (str(v_value)) standardKeys = [ ("gm", getGameModeId(bf2.serverSettings.getGameMode())), ("m", getMapId(bf2.serverSettings.getMapName())), ("v", str(v_value)), ("pc", len(statsMap)), ] # only send rwa key if there was a winner winner = bf2.gameLogic.getWinner() if winner != 0: standardKeys += [("rwa", roundArmies[winner])] # get final ticket score if g_debug: print "Army 1 (%s) Score: %s" % (str( roundArmies[1]), str(bf2.gameLogic.getTickets(1))) if g_debug: print "Army 2 (%s) Score: %s" % (str( roundArmies[2]), str(bf2.gameLogic.getTickets(2))) standardKeys += [ ("ra1", str(roundArmies[1])), ("rs1", str(bf2.gameLogic.getTickets(1))), ("ra2", str(roundArmies[2])), ("rs2", str(bf2.gameLogic.getTickets(2))), ] standardKeys += [("rst2", str(bf2.gameLogic.getTickets(2)))] stdKeyVals = [] for k in standardKeys: stdKeyVals.append("\\".join((k[0], str(k[1])))) snapShot += "\\".join(stdKeyVals) if g_debug: print 'Snapshot Pre-processing complete: %s' % (str(snapShot)) playerSnapShots = "" if g_debug: print 'Num clients to base snap on: %d' % (len(statsMap)) for sp in statsMap.itervalues(): if g_debug: print 'Processing PID: %s' % (str(sp.profileId)) playerSnapShots += getPlayerSnapshot(sp) print "Doing Player SNAPSHOTS" snapShot += playerSnapShots # Add EOF marker for validation snapShot += "\\EOF\\1" return snapShot
def getSnapShot(): print "Assembling snapshot" # Added by Chump - for bf2statistics stats #snapShot = "\\" #global PREFIX, map_start global map_start snapShot = snapshot_prefix + '\\' + bf2.gameLogic.getMapName() + '\\' snapShot += 'gameport\\' + str( bf2.serverSettings.getServerConfig('sv.serverPort')) + '\\' snapShot += 'queryport\\' + str( bf2.serverSettings.getServerConfig('sv.gameSpyPort')) + '\\' snapShot += 'mapstart\\' + str(map_start) + '\\mapend\\' + str( time()) + '\\' snapShot += 'win\\' + str(bf2.gameLogic.getWinner()) + '\\' statsMap = getStatsMap() # ---------------------------------------------------------------------------- # omero 2006-04-10 # ---------------------------------------------------------------------------- # this will be used for detecting which mod is running and # set standardKeys['v'] accordingly # defaults to 'bf2' # running_mod = str(host.sgl_getModDirectory()) if (running_mod.lower() == 'mods/bf2'): v_value = 'bf2' elif (running_mod.lower() == 'mods/bf2sp64'): v_value = 'bf2sp64' elif (running_mod.lower() == 'mods/xpack'): v_value = 'xpack' elif (running_mod.lower() == 'mods/poe2'): v_value = 'poe2' elif (running_mod.lower() == 'mods/aix2'): v_value = 'aix2' else: v_value = 'bf2' if g_debug: print 'Running MOD: %s' % (str(v_value)) standardKeys = [ # Added by Chump - for bf2statistics stats ("gm", getGameModeId(bf2.serverSettings.getGameMode())), ("m", getMapId(bf2.serverSettings.getMapName())), # Added by Chump - for bf2statistics stats ("v", str(v_value)), ("pc", len(statsMap)), ] # only send rwa key if there was a winner winner = bf2.gameLogic.getWinner() if winner != 0: standardKeys += [("rwa", roundArmies[winner])] # get final ticket score if g_debug: print "Army 1 (%s) Score: %s" % (str( roundArmies[1]), str(bf2.gameLogic.getTickets(1))) if g_debug: print "Army 2 (%s) Score: %s" % (str( roundArmies[2]), str(bf2.gameLogic.getTickets(2))) standardKeys += [ ("ra1", str(roundArmies[1])), ("rs1", str(bf2.gameLogic.getTickets(1))), ("ra2", str(roundArmies[2])), ("rs2", str(bf2.gameLogic.getTickets(2))), ] standardKeys += [("rst2", str(bf2.gameLogic.getTickets(2)))] stdKeyVals = [] for k in standardKeys: stdKeyVals.append("\\".join((k[0], str(k[1])))) snapShot += "\\".join(stdKeyVals) if g_debug: print 'Snapshot Pre-processing complete: %s' % (str(snapShot)) playerSnapShots = "" if g_debug: print 'Num clients to base snap on: %d' % (len(statsMap)) for sp in statsMap.itervalues(): if g_debug: print 'Processing PID: %s' % (str(sp.profileId)) playerSnapShot = getPlayerSnapshot(sp) # Added by Chump - for bf2statistics stats playerSnapShots += playerSnapShot # remove zero vals #zeroAllowedKeys = ('pid', 'a', 'mvns', 'mvks', 'vmns', 'vmks') #transformedSnapShot = "" #i = 0 #while i < len(playerSnapShot): # i += 1 # key = "" # while playerSnapShot[i] != "\\": # key += playerSnapShot[i] # i += 1 # i += 1 # value = "" # while i < len(playerSnapShot) and playerSnapShot[i] != "\\": # value += playerSnapShot[i] # i += 1 # if value != "0" or key[:key.find('_')] in zeroAllowedKeys: # keyVal = "\\" + key + "\\" + value # transformedSnapShot += keyVal #if len(transformedSnapShot) > 0: # playerSnapShots += transformedSnapShot print "Doing Player SNAPSHOTS" snapShot += playerSnapShots # Add EOF marker for validation snapShot += "\\EOF\\1" return snapShot
def getSnapShot(): print "Assembling snapshot" global map_start statsMap = getStatsMap() # ---------------------------------------------------------------------------- # Wilson212 2016-06-24 # ---------------------------------------------------------------------------- # Changed standardKeys['v'] from mod, to python version! # standardKeys['m'] is now for mod name # running_mod = str(host.sgl_getModDirectory()) running_mod = running_mod.lower().replace("mods/", "") if g_debug: print 'Running MOD: %s' % running_mod standardKeys = [ ("authId", str(stats_auth_id)), ("authToken", str(stats_auth_token)), ("serverName", str(bf2.serverSettings.getServerConfig('sv.serverName'))), ("gamePort", str(bf2.serverSettings.getServerConfig('sv.serverPort'))), ("queryPort", str(bf2.serverSettings.getServerConfig('sv.gameSpyPort'))), ("mapId", str(getMapId(bf2.serverSettings.getMapName()))), ("mapName", str(bf2.gameLogic.getMapName())), ("mapStart", str(map_start)), ("mapEnd", str(time())), ("winner", str(bf2.gameLogic.getWinner())), ("gameMode", str(getGameModeId(bf2.serverSettings.getGameMode()))), ("mod", str(running_mod)), ("version", "3.0"), ("pc", len(statsMap)), ] if g_debug: print 'Finished Pre-Compile SNAPSHOT' # only send rwa key if there was a winner winner = bf2.gameLogic.getWinner() if winner != 0: standardKeys += [("rwa", roundArmies[winner])] # get final ticket score if g_debug: print "Army 1 (%s) Score: %s" % (str(roundArmies[1]), str(bf2.gameLogic.getTickets(1))) if g_debug: print "Army 2 (%s) Score: %s" % (str(roundArmies[2]), str(bf2.gameLogic.getTickets(2))) standardKeys += [ ("ra1", str(roundArmies[1])), ("rs1", str(bf2.gameLogic.getTickets(1))), ("ra2", str(roundArmies[2])), ("rs2", str(bf2.gameLogic.getTickets(2))), ] standardKeys += [("rst2", str(bf2.gameLogic.getTickets(2)))] stdKeyVals = [] for k in standardKeys: stdKeyVals.append (":".join(( '"' + str(k[0]) + '"', '"' + str(k[1]) + '"'))) snapShot = "{" snapShot += ",".join(stdKeyVals) if g_debug: print 'Snapshot Pre-processing complete: %s' % (str(snapShot)) playerSnapShots = [] if g_debug: print 'Num clients to base snap on: %d' % (len(statsMap)) for sp in statsMap.itervalues(): if g_debug: print 'Processing PID: %s' % (str(sp.profileId)) playerSnap = getPlayerSnapshot(sp) if len(playerSnap) > 0: playerSnapShots.append (playerSnap) print "Doing Player SNAPSHOTS" snapShot += ',"players":[' + ",".join(playerSnapShots) + ']' # Add EOF marker for validation snapShot += "}" return snapShot
def getSnapShot(): print "Assembling snapshot" global map_start snapShot = snapshot_prefix + '\\' + str(bf2.serverSettings.getServerConfig('sv.serverName')) + '\\' snapShot += 'gameport\\' + str(bf2.serverSettings.getServerConfig('sv.serverPort')) + '\\' snapShot += 'queryport\\' + str(bf2.serverSettings.getServerConfig('sv.gameSpyPort')) + '\\' snapShot += 'mapname\\' + str(bf2.gameLogic.getMapName()) + '\\' snapShot += 'mapid\\' + str(getMapId(bf2.serverSettings.getMapName())) + '\\' snapShot += 'mapstart\\' + str(map_start) + '\\mapend\\' + str(time()) + '\\' snapShot += 'win\\' + str(bf2.gameLogic.getWinner()) + '\\' if g_debug: print 'Finished Pre-Compile SNAPSHOT' statsMap = getStatsMap() # ---------------------------------------------------------------------------- # omero 2006-04-10 # ---------------------------------------------------------------------------- # this will be used for detecting which mod is running and # set standardKeys['v'] accordingly # defaults to 'bf2' # running_mod = str(host.sgl_getModDirectory()) if ( running_mod.lower() == 'mods/bf2' ): v_value = 'bf2' elif ( running_mod.lower() == 'mods/bf2sp64' ): v_value = 'bf2sp64' elif ( running_mod.lower() == 'mods/xpack' ): v_value = 'xpack' elif ( running_mod.lower() == 'mods/poe2' ): v_value = 'poe2' elif ( running_mod.lower() == 'mods/aix2' ): v_value = 'aix2' else: v_value = 'bf2' if g_debug: print 'Running MOD: %s' % (str(v_value)) standardKeys = [ ("gm", getGameModeId(bf2.serverSettings.getGameMode())), ("m", getMapId(bf2.serverSettings.getMapName())), ("v", str(v_value)), ("pc", len(statsMap)), ] # only send rwa key if there was a winner winner = bf2.gameLogic.getWinner() if winner != 0: standardKeys += [("rwa", roundArmies[winner])] # get final ticket score if g_debug: print "Army 1 (%s) Score: %s" % (str(roundArmies[1]), str(bf2.gameLogic.getTickets(1))) if g_debug: print "Army 2 (%s) Score: %s" % (str(roundArmies[2]), str(bf2.gameLogic.getTickets(2))) standardKeys += [ ("ra1", str(roundArmies[1])), ("rs1", str(bf2.gameLogic.getTickets(1))), ("ra2", str(roundArmies[2])), ("rs2", str(bf2.gameLogic.getTickets(2))), ] standardKeys += [("rst2", str(bf2.gameLogic.getTickets(2)))] stdKeyVals = [] for k in standardKeys: stdKeyVals.append ("\\".join((k[0], str(k[1])))) snapShot += "\\".join(stdKeyVals) if g_debug: print 'Snapshot Pre-processing complete: %s' % (str(snapShot)) playerSnapShots = "" if g_debug: print 'Num clients to base snap on: %d' % (len(statsMap)) for sp in statsMap.itervalues(): if g_debug: print 'Processing PID: %s' % (str(sp.profileId)) playerSnapShots += getPlayerSnapshot(sp) print "Doing Player SNAPSHOTS" snapShot += playerSnapShots # Add EOF marker for validation snapShot += "\\EOF\\1" return snapShot
from bf2.stats.miniclient import miniclient, http_get # Import relevant medals data (BF2, Xpack, or Custom) if (medals_custom_data != ''): try: exec 'from bf2.stats.medal_data_' + str(medals_custom_data) + ' import *' except: print "Custom Medals Data Pack (%s) *NOT* found or is corrupt!" % (str(medals_custom_data)) # Use defualt medals_data instead from bf2.stats.medal_data import * else: print "Custom Medals Data Pack (%s) loaded." % (str(medals_custom_data)) else: # Most MODs don't use SF medals, so we'll default to bf2 medals_data running_mod = str(host.sgl_getModDirectory()) if ( running_mod.lower() == 'mods/xpack' ): from bf2.stats.medal_data_xpack import * else: from bf2.stats.medal_data import * # Get Player Stats Data from bf2.stats.stats import getStatsMap, getPlayerConnectionOrderIterator, setPlayerConnectionOrderIterator # ------------------------------------------------------------------------------ # mimics onPlayerStatsResponse() # ------------------------------------------------------------------------------ def attachPlayerStats(player,stats):
# + Improved custom medals data loading # ------------------------------------------------------------------------------ import host import bf2.PlayerManager import bf2.Timer import os from bf2 import g_debug from bf2.stats.constants import * from bf2.BF2StatisticsConfig import http_backend_addr, http_backend_port, medals_custom_data, medals_force_keystring from bf2.stats.miniclient import miniclient, http_get # Import relevant medals data (BF2, Xpack, or Custom) running_mod = str(host.sgl_getModDirectory()) if (running_mod.lower() == 'mods/xpack'): if (medals_custom_data != ''): try: exec 'from bf2.stats.medal_data_xpack_' + str( medals_custom_data) + ' import *' except: print "Custom Medals Xpack Data Pack (%s) *NOT* found or is corrupt!" % ( str(medals_custom_data)) # Use defualt medals_data instead from bf2.stats.medal_data_xpack import * else: print "Custom Medals Xpack Data Pack (%s) loaded." % ( str(medals_custom_data)) else: from bf2.stats.medal_data_xpack import *