def onKickCommand(cn, args): '''@description Kick player from the server without ban time @usage <cn>''' tcn = int(args) t = player(tcn) serverMessage(info(kick_message.substitute(colordict, name=p.name()))) t.kick()
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 announce(cn): p = player(cn) msg = string.Template(template).substitute(colordict, user=p.name(), country=getCountry(p.ipLong())) serverMessage(info(msg))
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 onClearBansCmd(cn, args): '''@description Remove active bans @usage''' clearBans() serverMessage(info('Bans cleared'))
def reqClearBans(cn): clearBans() serverMessage(info('Bans cleared'))
def onUploadMap(cn): p = player(cn) serverMessage(info(uptemp.substitute(colordict, name=p.name())))
def getmap(cn): p = player(cn) serverMessage(info(getmaptemp.substitute(colordict, name=p.name())))
def teamkill_broadcast(cn, tcn): tker = player(cn) target = player(tcn) serverMessage(info(tktemp.substitute(colordict, tker=tker.name(), victim=target.name(), tkcount=tker.teamkills())))