The change of gamemodes
dm to tdm
tdm to dm
dm to coop
Etc.
Does not work after once mapchange I have to change the map twice
The code was written at the beginning of SP I think it is outdated
Thanks in Advance
Syntax: Select all
import os
from cvars import cvar
from listeners import OnLevelInit
from listeners.tick import Delay
from paths import BASE_PATH, GAME_PATH
from supermod import functions
#from supermod.modules import mapvoting
import core
from supermod.cfg.mapcycle import mapcycle
core.console_message("\n[Supermod] Mapconfig loaded!")
maps = []
cfgpath = BASE_PATH + '/plugins/supermod/cfg/mapconfigs/'
for (dirpath, dirnames, filenames) in os.walk(cfgpath):
for map in filenames:
map = map.replace('.cfg', '')
maps.append(map)
for x in mapcycle:
for y in mapcycle[x]:
cfg = cfgpath + y + '.cfg'
if not os.path.exists(cfg):
with cfg.open('w') as f:
pass
@OnLevelInit
def map_start(mapname):
if mapname in maps:
Delay(1, execute_config, (mapname,))
def execute_config(mapname):
mappath = cfgpath + mapname + '.cfg'
with mappath.open('r') as f:
commands = f.readlines()
commands = [command.replace('\n', '') for command in commands]
if not commands:
execute_config("map_default")
for command in commands:
if command.startswith('//') or not command:
continue
#if command.startswith('sm_nextmap'):
#mapvoting.disable_mapvoting()
functions.servercommand(command)
#tp = cvar.find_var('mp_teamplay')
'''if 'teamplay' in commands:
if tp.get_int() == 0:
tp.set_int(1)
Delay(1, functions.servercommand, ('changelevel ' + mapname,))
else:
if tp.get_int() == 1:
tp.set_int(0)
Delay(1, functions.servercommand, ('changelevel ' + mapname,))'''