[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: 490
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: 490
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))
User avatar
Ayuto
Project Leader
Posts: 2022
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

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

Postby Ayuto » Tue May 28, 2019 8:26 pm

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

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

Postby Painkiller » Tue May 28, 2019 8:33 pm

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.
User avatar
Ayuto
Project Leader
Posts: 2022
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

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

Postby Ayuto » Tue May 28, 2019 8:41 pm

Did you add mp_teamplay <mode> to the correct map config file?
User avatar
Painkiller
Senior Member
Posts: 490
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

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

Postby Painkiller » Tue May 28, 2019 8:49 pm

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

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

Postby Painkiller » Wed Jun 12, 2019 11:33 am

Are there any new findings ?
User avatar
Painkiller
Senior Member
Posts: 490
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

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

Postby Painkiller » Sat Jun 29, 2019 8:38 pm

Hello @Ayuto, are there any new findings yet?
User avatar
Ayuto
Project Leader
Posts: 2022
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

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

Postby Ayuto » Sun Jun 30, 2019 3:05 am

No, I will tell you if I have something.
User avatar
Painkiller
Senior Member
Posts: 490
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

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

Postby Painkiller » Mon Sep 02, 2019 11:54 am

Hello is there after this long time please a solution?
User avatar
L'In20Cible
Project Leader
Posts: 1162
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

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

Postby L'In20Cible » Mon Sep 02, 2019 2:58 pm

I've tested Ayuto's code posted there and it is working fine for me:
Ayuto wrote: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,))'''
User avatar
Painkiller
Senior Member
Posts: 490
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

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

Postby Painkiller » Mon Sep 02, 2019 6:52 pm

I tested it. It's not working.

this code is current on my server.

If you have a moment I would show it to you.
User avatar
L'In20Cible
Project Leader
Posts: 1162
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

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

Postby L'In20Cible » Mon Sep 02, 2019 7:32 pm

Painkiller wrote:I tested it. It's not working.

this code is current on my server.

If you have a moment I would show it to you.

Try to replace the following line:

Syntax: Select all

Delay(0, execute_config, [global_vars.map_name])

To:

Syntax: Select all

Delay(1, execute_config, [global_vars.map_name])

I believe on some system the execution of cfg files that contains ConVars mixed with queued commands can results into the later being executed first and overridden by the file afterword as both are technically done in the next frame with a delay of 0 second.
User avatar
Painkiller
Senior Member
Posts: 490
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

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

Postby Painkiller » Mon Sep 02, 2019 8:16 pm

It's still not working.

If you have time I like to let you on my server with FTP access?

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 4 guests