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

A place for requesting new Source.Python plugins to be made for your server.

Please request only one plugin per thread.
User avatar
Painkiller
Senior Member
Posts: 448
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

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

Postby Painkiller » Thu May 02, 2019 2:01 pm

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,))'''
User avatar
Painkiller
Senior Member
Posts: 448
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

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

Postby Painkiller » Wed May 08, 2019 3:09 pm

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

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 2 guests