This is
TB_ wrote:a script that changes the map based on how many players who are onlineIdea by TB_: More info HERE
script:
Code: Select all
To set up a custom rotation put the line "map_threshold" in config.txt
"""
thepolm3
idea @ TB_
"""
from twisted.internet.task import LoopingCall
from map import check_rotation
from commands import add
from random import randint
def intelimap(connection):
connection.protocol.overruled=not connection.protocol.ovveruled
return ("intelimap is" + ["ON","OFF"][connection.protocol.ovveruled] + "This round")
add(intelimap)
threshold=[]
def apply_script(protocol, connection, config):
class MapProtocol(protocol):
overruled=False
def check_next_map(self):
if not self.overruled:
nop=len(self.players)
for i in range(len(threshold)-1):
if threshold[i] == threshold[i+1]:
for a in range(i,len(threshold)-1):
if threshold[a] != threshold[i]:
break
if threshold[a-1]<= nop < threshold[a]:
mapindex=randint(i,a-1)
break
else:
i=a
elif threshold[i] <= nop < threshold[i+1]:
mapindex=i
break
else:
mapindex=len(threshold)-1
self.planned_map=check_rotation([self.get_map_rotation()[mapindex]])[0]
def on_command(self,command,sender):
if command=="map" and sender.admin:
self.overruled=True
protocol.on_command(self,command,sender)
def on_map_change(self,map):
global threshold
self.overruled=False
threshold=config.get("map_threshold",[])
if threshold==[]:
nop=self.max_players
rot=self.get_map_rotation()
step=nop/len(rot)
for i in range(len(rot)):
threshold.append(i*step)
checking=LoopingCall(self.check_next_map)
checking.start(1)
protocol.on_map_change(self,map)
return MapProtocol, connection
Code: Select all
so if these were in your config, when the map advances with 14 players it is random, with 3 it is a random [hallway, platform, skullisland], with 17 it is hallway and with 9 it is classicgen "maps" : ["hallway","platform","skullisland","pinpoint","classicgen","random","hallway"],
"map_threshold" : [0,0,0,4,8,12,16],
Edit: Made the random feature a reality!
Edit: Fixed the reality!