def countVotes(): players = allPlayers() votes_needed = (len(players) / 2) bestmap = '' bestmode = 0 bestcount = 0 candidates = [] for p in allPlayers(): try: pv = p.gamevars['mapvote'] count = vote(candidates, pv) if count > bestcount: bestmap = pv[0] bestmode = pv[1] bestcount = count except (AttributeError, KeyError): pass if bestcount > votes_needed: serverMessage(info('Vote passed.')) setMap(bestmap, bestmode)
def persistentTeams(enabled): if enabled == True: del player_pteams[:] for p in allPlayers(): try: if p.team() != '': player_pteams.append((p.cn, p.team())) except ValueError: pass elif enabled == False: del player_pteams[:] else: raise ValueError('Enabled must be boolean value')
def persistentTeams(enabled): if enabled == True: del player_pteams[:] for p in allPlayers(): try: if p.team() != "": player_pteams.append((p.cn, p.team())) except ValueError: pass elif enabled == False: del player_pteams[:] else: raise ValueError("Enabled must be boolean value")
def checkVotes(cn): players = allPlayers() needed = len(players) / 2 if needed <= 1: needed += 1 votes = 0 for player in players: try: if player.votekick == cn: votes += 1 except AttributeError: pass if votes >= needed: ban(cn, 3600, 'Vote', -1)
def onIntermission(): players = allPlayers() most_frags = 0 most_frags_cn = 0 most_tks = 0 most_tks_cn = -1 most_deaths = 0 most_deaths_cn = -1 most_accuracy = 0 most_accurate_cn = -1 if newawards_enabled: most_doublekills = 0 most_doublekills_cn = -1 most_triplekills = 0 most_triplekills_cn = -1 most_overkills = 0 most_overkills_cn = -1 most_killtaculars = 0 most_killtaculars_cn = -1 most_killotrocities = 0 most_killotrocities_cn = -1 most_killtastrophes = 0 most_killtastrophes_cn = -1 most_killapocalypses = 0 most_killapocalypses_cn = -1 most_killionaires = 0 most_killionaires_cn = -1 for p in players: try: frags = p.frags() teamkills = p.teamkills() deaths = p.deaths() accuracy = p.accuracy() if frags > most_frags or most_frags_cn == -1: most_frags = frags most_frags_cn = p.cn if teamkills > most_tks or most_tks_cn == -1: most_tks = teamkills most_tks_cn = p.cn if deaths > most_deaths or most_deaths_cn == -1: most_deaths = deaths most_deaths_cn = p.cn if accuracy > most_accuracy or most_accurate_cn == -1: most_accuracy = accuracy most_accurate_cn = p.cn except ValueError: continue if newawards_enabled: try: try: doublekills = p.ownagedata.multikill_counts[2] except KeyError: doublekills = 0 try: triplekills = p.ownagedata.multikill_counts[3] except KeyError: triplekills = 0 try: overkills = p.ownagedata.multikill_counts[5] except KeyError: overkills = 0 try: killtaculars = p.ownagedata.multikill_counts[7] except KeyError: killtaculars = 0 try: killotrocities = p.ownagedata.multikill_counts[10] except KeyError: killotrocities = 0 try: killtastrophes = p.ownagedata.multikill_counts[15] except KeyError: killtastrophes = 0 try: killapocalypses = p.ownagedata.multikill_counts[20] except KeyError: killapocalypses = 0 try: killionaires = p.ownagedata.multikill_counts[25] except KeyError: killionaires = 0 if newawards_enabled: if doublekills > most_doublekills or most_doublekills_cn == -1: most_doublekills = doublekills most_doublekills_cn = p.cn if triplekills > most_triplekills or most_triplekills_cn == -1: most_triplekills = triplekills most_triplekills_cn = p.cn if overkills > most_overkills or most_overkills_cn == -1: most_overkills = overkills most_overkills_cn = p.cn if killtaculars > most_killtaculars or most_killtaculars_cn == -1: most_killtaculars = killtaculars most_killtaculars_cn = p.cn if killotrocities > most_killotrocities or most_killotrocities_cn == -1: most_killotrocities = killotrocities most_killotrocities_cn = p.cn if killtastrophes > most_killtastrophes or most_killtastrophes_cn == -1: most_killtastrophes = killtastrophes most_killtastrophes_cn = p.cn if killapocalypses > most_killapocalypses or most_killapocalypses_cn == -1: most_killapocalypses = killapocalypses most_killapocalypses_cn = p.cn if killionaires > most_killionaires or most_killionaires_cn == -1: most_killionaires = killionaires most_killionaires_cn = p.cn except (KeyError, ValueError): continue msg = '' if most_frags > 0: msg += mftemp.substitute(colordict, name=player(most_frags_cn).name(), count=most_frags) msg += ' ' if most_tks > 0: msg += mtktemp.substitute(colordict, name=player(most_tks_cn).name(), count=most_tks) msg += ' ' if most_deaths > 0: msg += mdtemp.substitute(colordict, name=player(most_deaths_cn).name(), count=most_deaths) msg += ' ' if most_accuracy > 0: msg += matemp.substitute(colordict, name=player(most_accurate_cn).name(), count=most_accuracy) if newawards_enabled: if most_doublekills > 0: msg += most_doublekillstemp.substitute(colordict, name=player(most_doublekills_cn).name(), count=most_doublekills) msg += ' ' if most_triplekills > 0: msg += most_triplekillstemp.substitute(colordict, name=player(most_triplekills_cn).name(), count=most_triplekills) msg += ' ' if most_overkills > 0: msg += most_overkillstemp.substitute(colordict, name=player(most_overkills_cn).name(), count=most_overkills) msg += ' ' if most_killtaculars > 0: msg += most_killtacularstemp.substitute(colordict, name=player(most_killtaculars_cn).name(), count=most_killtaculars) msg += ' ' if most_killotrocities > 0: msg += most_killotrocitiestemp.substitute(colordict, name=player(most_killotrocities_cn).name(), count=most_killotrocities) msg += ' ' if most_killtastrophes > 0: msg += most_killtastrophestemp.substitute(colordict, name=player(most_killtastrophes_cn).name(), count=most_killtastrophes) msg += ' ' if most_killapocalypses > 0: msg += most_killapocalypsestemp.substitute(colordict, name=player(most_killapocalypses_cn).name(), count=most_killapocalypses) msg += ' ' if most_killionaires > 0: msg += most_killionairestemp.substitute(colordict, name=player(most_killionaires_cn).name(), count=most_killionaires) msg += ' ' if msg != '': msg = awards_prefix + msg serverMessage(msg)
def __init__(self): players = allPlayers() for p in players: p.ownagedata = ownageData(p.cn)