Page 1 of 1

[HL2:DM] Mapconfig Plugin no longer work :(

Posted: Thu May 02, 2019 2:01 pm
by Painkiller
Unfortunately, this config only partially works.

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,))'''

Re: [HL2:DM] Mapconfig Plugin no longer work :(

Posted: Wed May 08, 2019 3:09 pm
by Painkiller
How could I use that in my script?

VinciT wrote:This should do the trick:

Code: Select all

from listeners import OnLevelShutdown
from engines.server import engine_server

GAMEMODE = 0

@OnLevelShutdown
def change_gamemode():
   global GAMEMODE
   GAMEMODE = 1 - GAMEMODE

   engine_server.server_command('mp_teamplay ' + str(GAMEMODE))

Re: [HL2:DM] Mapconfig Plugin no longer work :(

Posted: Tue May 28, 2019 8:26 pm
by Ayuto
Try this quick and dirty edit:

Syntax: Select all

import os

from cvars import cvar

from listeners.tick import Delay

from paths import BASE_PATH, GAME_PATH
from commands.server import ServerCommand
from listeners.tick import Delay
from engines.server import global_vars

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

@ServerCommand('exec')
def pre_exec(command):
if global_vars.map_name not in maps:
return

config = command[1]
if config == 'server.cfg':
Delay(0, execute_config, [global_vars.map_name])

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 and mapname != 'map_default': # Fixed the possible recursion here
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,))'''

Re: [HL2:DM] Mapconfig Plugin no longer work :(

Posted: Tue May 28, 2019 8:33 pm
by Painkiller
Unfortunately, that doesn't work either.
Also don't get any errors.

I wanted to switch from a dm map to a coop map and it stayed at dm.

Re: [HL2:DM] Mapconfig Plugin no longer work :(

Posted: Tue May 28, 2019 8:41 pm
by Ayuto
Did you add mp_teamplay <mode> to the correct map config file?

Re: [HL2:DM] Mapconfig Plugin no longer work :(

Posted: Tue May 28, 2019 8:49 pm
by Painkiller
Yes i have in coop_resident_evil_sg_zb4.cfg

Code: Select all

hostname "Irrenanstallt [Rocks] | Coop -> 18+ | FastDL"

mp_fraglimit 0
deathmatch 0
mp_teamplay 1
coop1
mp_timelimit 0


game_description "Co-op"

Re: [HL2:DM] Mapconfig Plugin no longer work :(

Posted: Wed Jun 12, 2019 11:33 am
by Painkiller
Are there any new findings ?

Re: [HL2:DM] Mapconfig Plugin no longer work :(

Posted: Sat Jun 29, 2019 8:38 pm
by Painkiller
Hello @Ayuto, are there any new findings yet?

Re: [HL2:DM] Mapconfig Plugin no longer work :(

Posted: Sun Jun 30, 2019 3:05 am
by Ayuto
No, I will tell you if I have something.