def _getMapList(self, client=None): try: from b3 import maplist as mplist except: return self.console.getMaps() else: if client: if client.maxLevel >= self._min_maps_level: maplist = self.console.getMaps() else: maplist = mplist.listCycleMaps(self.console) else: maplist = mplist.listCycleMaps(self.console) return maplist
def cmd_zmaps(self, data, client=None, cmd=None): """\ - list the server's map rotation [name] - list maps matching name [N] - list maps by page number """ if not self._adminPlugin.aquireCmdLock(cmd, client, 60, True): client.message('^7Do not spam commands') return maxList = 30 page = None maps = maplist.listCycleMaps(self.console) if maps: if data: if data.isdigit(): page = int(data) if page == 0: client.message('^7Invalid page number') return else: self.debug('List len %d' % len(maps)) if len(maps)<=maxList: total = 1 else: ft = float(len(maps))/float(maxList) it = len(maps)/maxList if ft > it: total = it+1 else: total = it if page > total: client.message('^7Page doesn\'t exists. Total pages %d' % total) return showpage = page * maxList if showpage > len(maps): showpage = len(maps) maps = maps[showpage-maxList:showpage] else: data = data.strip().lower() nmaps = [] for m in maps: if m.lower().find(data)>-1: nmaps.append(m) maps = nmaps if len(maps)>maxList: if data: client.message('^7Map list is too big. Try to be more specific.') else: client.message('^7Map list is too big. Try !maps <name> to filter the list.') else: if page: cmd.sayLoudOrPM(client, '^7Map list [page %d of %d]: ^2%s' % (page,total,string.join(maps, '^7, ^2'))) else: cmd.sayLoudOrPM(client, '^7Map list: ^2%s' % string.join(maps, '^7, ^2')) else: client.message('^7Error: could not get map list')
def getMapList(self): try: from b3 import maplist except: self.debug("Using alternative map list method") maps = self.console.getMaps() else: maps = maplist.listCycleMaps(self.console) return maps
def cmd_zmap(self, data, client, cmd=None): """\ <map> - switch current map """ if not data: client.message('^7You must supply a map to change to.') return try: mfile = maplist.listCycleMaps(self.console, data) self.console.say('^7Changing map to %s' % mfile) time.sleep(1) self.console.write('map %s' % mfile) return True except Exception, e: client.message('^7%s' % str(e)) return False
def cmd_zsetnextmap(self, data, client, cmd=None): """\ <mapname> - Set the nextmap. """ if not data: client.message('^7Invalid or missing data, try !help setnextmap') return False try: mfile = maplist.listCycleMaps(self.console, data) self.console.write('g_nextmap "%s"' % mfile) map = self.console.getNextMap() self.console.say('^7Nextmap is: ^2%s' % map) return True except Exception, e: client.message('^7%s' % str(e)) return False
def cmd_zsetnextmap(self, data, client, cmd=None): """\ <mapname> - Set the nextmap. """ if not data: client.message('^7Invalid or missing data, try !help setnextmap') return False try: mfile = maplist.listCycleMaps(self.console, data) self.console.write( 'g_nextmap "%s"' % mfile ) map = self.console.getNextMap() self.console.say('^7Nextmap is: ^2%s' % map) return True except Exception, e: client.message('^7%s' % str(e)) return False
def cmd_zmaps(self, data, client=None, cmd=None): """\ - list the server's map rotation [name] - list maps matching name [N] - list maps by page number """ if not self._adminPlugin.aquireCmdLock(cmd, client, 60, True): client.message('^7Do not spam commands') return maxList = 30 page = None maps = maplist.listCycleMaps(self.console) if maps: if data: if data.isdigit(): page = int(data) if page == 0: client.message('^7Invalid page number') return else: self.debug('List len %d' % len(maps)) if len(maps) <= maxList: total = 1 else: ft = float(len(maps)) / float(maxList) it = len(maps) / maxList if ft > it: total = it + 1 else: total = it if page > total: client.message( '^7Page doesn\'t exists. Total pages %d' % total) return showpage = page * maxList if showpage > len(maps): showpage = len(maps) maps = maps[showpage - maxList:showpage] else: data = data.strip().lower() nmaps = [] for m in maps: if m.lower().find(data) > -1: nmaps.append(m) maps = nmaps if len(maps) > maxList: if data: client.message( '^7Map list is too big. Try to be more specific.') else: client.message( '^7Map list is too big. Try !maps <name> to filter the list.' ) else: if page: cmd.sayLoudOrPM( client, '^7Map list [page %d of %d]: ^2%s' % (page, total, string.join(maps, '^7, ^2'))) else: cmd.sayLoudOrPM( client, '^7Map list: ^2%s' % string.join(maps, '^7, ^2')) else: client.message('^7Error: could not get map list')
def getMapList(self): return maplist.listCycleMaps(self.console)