Beispiel #1
0
 def scorewatch(self):
     while self.running:
         try:
             data = self.rcon.send('serverInfo')
             self.team1score = data[9]
             self.team2score = data[10]
             self.map = data[5].strip('Levels/')
             self.gametype = data[4]
         except Exception, error:
             self.log.error('error in watching scores %s' % error)
         try:
             self.serverrank, self.serverperc = functions.rank_scrape()
         except Exception, error:
             self.log.error('error in scraping rank: %s' % error)
Beispiel #2
0
 def first_run(self):
     self.players.addchat('Server', 'There is hope!  Monitor has a pulse!')
     if not self.rcon:
         self.rcon = rcon.Rcon(self.config.get('server', 'ip'), int(self.config.get('server', 'port')), self.config.get('server', 'pass'))
         self.rcon.connect()
         self.rcon.login()
     '''
     OK <serverName: string> <current playercount: integer> <max playercount: integer> 
     <current gamemode: string> <current map: string> 
     <roundsPlayed: integer> <roundsTotal: string> <scores: team scores>
     '''
     initialdata = self.rcon.send('serverInfo')
     self.servername = initialdata[1]
     self.currentplayers = initialdata[2]
     self.maxplayers = initialdata[3]
     self.gametype = initialdata[4]
     self.map = initialdata[5].strip('Levels/')
     self.currentround = initialdata[6]
     self.totalrounds = initialdata[7]
     self.team1score = initialdata[9]
     self.team2score = initialdata[10]
     self.serverrank, self.serverperc = functions.rank_scrape()
     
     initialdata = self.rcon.send('admin.listPlayers', 'all')
     initialdata = initialdata[1:]
     numparms = int(initialdata.pop(0))
     initialdata = initialdata[numparms:]
     for p in xrange(int(initialdata.pop(0))):
         self.players.connect(initialdata[1])
         player = self.players.getplayer(initialdata[1])
         player.tag = initialdata.pop(0)
         initialdata.pop(0)
         player.eaid = initialdata.pop(0)
         player.team = initialdata.pop(0)
         player.squad = initialdata.pop(0)
         player.kills = int(initialdata.pop(0))
         player.deaths = int(initialdata.pop(0))
         initialdata.pop(0)
         initialdata.pop(0)
         threading.Thread(target=functions.player_rank, args=[player]).start()
         #for i in xrange(numparms):
             #print initialdata.pop(0)
     self.rcon.disconnect()
     threading.Thread(target=self.scorewatch).start()