Skip to content

Instantly share code, notes, and snippets.

@zyuiop
Created March 6, 2016 19:18
Show Gist options
  • Save zyuiop/6f4d428ce3786959f04b to your computer and use it in GitHub Desktop.
Save zyuiop/6f4d428ce3786959f04b to your computer and use it in GitHub Desktop.
def createServer(gametype, maps, scoreLimit, basePort, portId):
# Main
hasRotation = len(maps) > 1
filename = ""
conf = "sv_name zyuiop.net - Public "
motd = "zyuiop's public Teeworlds servers - "
if hasRotation:
conf += gametype.upper()
filename = gametype
motd += gametype + " with all maps."
else:
conf += gametype.upper() + "/" + maps[0].upper()
filename = gametype + "-" + maps[0]
motd += gametype + " with map " + maps[0] + "."
conf += " server\n"
conf += "sv_map " + maps[0] + "\n"
if hasRotation:
conf += "sv_maprotation " + " ".join(maps) + "\n"
conf += "sv_gametype " + gametype + "\n"
conf += "sv_scorelimit " + scoreLimit + "\n"
conf += "sv_port " + basePort + portId + "\n"
conf += "logfile /home/zyuiop/tw-" + filename + ".log\n"
conf += motd
# Save
with open(filename + ".cfg", "w") as f:
f.write(conf)
# MAIN
gametype = input("Game Type : ")
maps = input("Maps : ").split(" ")
scoreLimit = input("Score Limit : ")
basePort = input("Base Port : ")
createServer(gametype, maps, scoreLimit, basePort, "0")
if len(maps) > 1:
i = 0
for m in maps:
createServer(gametype, [maps[i]], scoreLimit, basePort, str(i + 1))
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment