Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import SourceLib, threading, socket
- def GetInMS(seconds):
- minutes = seconds / 60
- seconds -= 60*minutes
- return "%02d:%02d" % (minutes, seconds)
- srcdsservers = ['Surf.TF2.Azelphur.com', 'Fun.TF2.Azelphur.com', 'Vanilla.TF2.Azelphur.com', 'FortWars.TF2.Azelphur.com']
- results = {}
- total = 0
- totalmax = 0
- threads = 0
- class TF2 ( threading.Thread ):
- def setserver(self, server):
- self.server = server
- def run ( self ):
- for i in range(0, 5):
- try:
- query = SourceLib.SourceQuery.SourceQuery(self.server, 27015)
- info = query.info()
- rules = query.rules()
- players = query.player()
- l = []
- l.append("%s" % (self.server))
- l.append("${goto 15}Map: %s" % (info['map']))
- l.append("${goto 15}Next Map: %s" % (rules['sm_nextmap']))
- l.append("${goto 15}Players: %s / %s" % (info['numplayers'], info['maxplayers']))
- l.append("${voffset -6}")
- results[self.server] = l
- global total, totalmax
- total += int(info['numplayers'])
- totalmax += int(info['maxplayers'])
- break
- except:
- l = []
- l.append("%s" % (self.server))
- l.append("${goto 15}Map: ?")
- l.append("${goto 15}Next Map: ?")
- l.append("${goto 15}Players: ? / ?")
- l.append("${voffset -6}")
- results[self.server] = l
- global threads
- threads -= 1
- self.checkresults()
- def checkresults(self):
- if threads != 0:
- return
- global total, totalmax
- print "Total: %d / %d (%d%%)" % (total, totalmax, (total*100)/totalmax)
- print
- for server in srcdsservers:
- for line in results[server]:
- print line
- exit()
- for server in srcdsservers:
- threads += 1
- p = TF2()
- p.setserver(server)
- p.start()
- #print
- #print "${alignc}Players"
- #plist = []
- #for player in players:
- # plist.append((player['kills'], player['name'].replace("$", '$$'), GetInMS(int(player['time']))))
- #plist = sorted(plist)
- #for player in reversed(plist):
- # print "%s${goto 210}%s${alignr}%s" % (player[1], player[0], player[2])
- #for i in range(0, 32-len(plist)):
- # print i+len(plist)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement