Jump to content

Recommended Posts

Posted

Cool that you shared this and showed how something can be automated. Could you also explain how to run it and how it works? Not everyone is a programmer, and maybe someone might want to use it.

 

There's a bit of a problem with the script, though. It doesn't account for the fact that pk3 package names don't match the .bsp names, so the script won't work. Sometimes a pk3 can have more than one map, or none at all, because someone could’ve thrown in a random pk3 that just changes character looks. If you uploaded that to the server, it could crash. It’d be great if you could add a check in each file to see what bsp files are inside.

 

unzip -l etdo_f2.pk3 | grep .bsp | cut -d'/' -f2

OUTPUT:
etdo1.bsp
etdo2.bsp
etdo3.bsp
etdo4.bsp
etdo5.bsp
etdo6.bsp
etdotj.bsp

 

  • Like 1
  • Thanks 2
  • ET Trial
Posted

Thanks! This is super helpful.

 

I did not know about the '.bsp' file distinction, probably explains my server instability problems :)

 

I *think* the latest commit should follow your advice, the example command was very helpful: https://git.sr.ht/~henesy/et-utils/commit/f66cd30f4526e9f6c20677a57aee3f3ffbe28611

 

README also present now for ease of reference with examples: https://git.sr.ht/~henesy/et-utils

  • Like 2
Posted (edited)

Nice one :) 

I use a python script for the same, saves a lot of time editing manually.


///// 

import os
import zipfile


pk3_dir = r"C:\Users\Phirox\Downloads\pk3"
pk3_files = [f for f in os.listdir(pk3_dir) if f.endswith(".pk3")]

#get .bsp name from a pk3 file
def get_bsp_name(pk3_file):
    with zipfile.ZipFile(pk3_file, 'r') as zip_ref:
        bsp_files = [f for f in zip_ref.namelist() if f.endswith(".bsp")]
        if bsp_files:
            # Return the first .bsp file found
            return os.path.splitext(os.path.basename(bsp_files[0]))[0]
        return None

config_lines = []
for i, pk3_file in enumerate(pk3_files, 1):
    pk3_path = os.path.join(pk3_dir, pk3_file)
    bsp_name = get_bsp_name(pk3_path)
    
    if bsp_name:
        next_map = f"d{i+1}" if i < len(pk3_files) else "d1"
        config_lines.append(f'set d{i} "set g_gametype 6 ; map {bsp_name}; set nextmap vstr {next_map}"')
    else:
        print(f"Warning: No .bsp file found in {pk3_file}")

config_lines.append("vstr d1")

with open("map_rotation.cfg", "w") as f:
    f.write("\n".join(config_lines))

print("Config file generated: map_rotation.cfg")

///////

 

for example see screens
 

1.JPG

 

2.JPG

 

3.JPG

Edited by phir0x
spaces
  • Like 2
  • 100 1
  • ET Trial
Posted

Ah excellent! 

 

Looks like we do more or less the same thing!

 

One thing I haven't looked at, but would like to is if there are any other rotations than mapvote and plain ol' ordinal rotation that I should account for. I haven't used any others, I only really play mapvote on my own servers.  

  • 100 1
Posted (edited)

I don't think that will be used much. But if I understand you correctly you mean this right ? 

This was a simple adjustment though.

The prompt:

print("Select the gametype:") print("2 = Objective, 3 = Stopwatch, 4 = Campaign, 5 = LMS, 6 = Mapvote") gametype = input("Enter the gametype number (e.g., 6 for Mapvote): ")

The validation:
if gametype not in ['2', '3', '4', '5', '6']: print("Invalid gametype selected. Defaulting to '6 = Mapvote'.") gametype = '6'

Config generation:
config_lines.append(f'set d{i} "set g_gametype {gametype} ; map {bsp_name}; set nextmap vstr {next_map}"')
 

 

 

4.JPG

 

 

5.JPG

Edited by phir0x
spaces

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.