HL2:DM-Skybox for all maps

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

Please request only one plugin per thread.
User avatar
daren adler
Senior Member
Posts: 328
Joined: Sat May 18, 2019 7:42 pm

HL2:DM-Skybox for all maps

Postby daren adler » Sun May 09, 2021 2:16 am

Could someone please make this for me :smile: I would like a skybox for all maps , I have 2 skybox's to use, 1) xen_sky_1 and 2) xen_sky_5. Would like them to be random please :wink: . heres the skybox's https://www.dropbox.com/s/trorfltzhko4d ... 9.zip?dl=0, THANK YOU :cool:

The old one looked somthing like this

Code: Select all

event es_map_start
{
   sv_skyname sky_day01_09
   es_setinfo thismap event_var(mapname)
}
User avatar
VinciT
Senior Member
Posts: 331
Joined: Thu Dec 18, 2014 2:41 am

Re: HL2:DM-Skybox for all maps

Postby VinciT » Mon May 10, 2021 3:23 am

Hi daren, I believe this should achieve what you want:

Syntax: Select all

# ../random_skybox/random_skybox.py

# Python
from random import choice

# Source.Python
from cvars import ConVar
from listeners import OnServerActivate
from paths import GAME_PATH
from stringtables.downloads import Downloadables


skyboxes = (
'xen_sky_1',
'xen_sky_5'
)


# Path to the '../hl2dm/materials/skybox/' folder.
SKYBOX_PATH = GAME_PATH / 'materials' / 'skybox'


downloads = Downloadables()
# Go through all the skybox names.
for skybox in skyboxes:
# Find all the necessary files for this skybox.
for file in SKYBOX_PATH.files(f'{skybox}*'):
base_name = file.basename()

# Exclude the file if it's compressed.
if base_name.endswith('.ztmp'):
continue

# Make sure the players download the file when connecting.
downloads.add(f'materials/skybox/{base_name}')


# Get the convar responsible for changing the skybox.
skyname_cvar = ConVar('sv_skyname')


@OnServerActivate
def on_server_activate(edicts, edict_count, max_clients):
"""Called when a map starts and the server is ready to accept clients."""
# Choose and set a random skybox.
skyname_cvar.set_string(choice(skyboxes))

Make sure to add all the necessary files to your server's ../hl2dm/materials/skybox/ folder. For example, the files for xen_sky_1 would be:

Code: Select all

xen_sky_1bk.vmt
xen_sky_1dn.vmt
xen_sky_1ft.vmt
xen_sky_1lf.vmt
xen_sky_1rt.vmt
xen_sky_1up.vmt
xen_sky_1_bk.vtf
xen_sky_1_dn.vtf
xen_sky_1_ft.vtf
xen_sky_1_hdr_bk.vtf
xen_sky_1_hdr_dn.vtf
xen_sky_1_hdr_ft.vtf
xen_sky_1_hdr_ft.vtf
xen_sky_1_hdr_lf.vtf
xen_sky_1_hdr_rt.vtf
xen_sky_1_hdr_up.vtf
xen_sky_1_lf.vtf
xen_sky_1_rt.vtf
xen_sky_1_up.vtf
ImageImageImageImageImage
User avatar
daren adler
Senior Member
Posts: 328
Joined: Sat May 18, 2019 7:42 pm

Re: HL2:DM-Skybox for all maps

Postby daren adler » Mon May 10, 2021 2:58 pm

:grin: Ok will do. Thank you :grin:

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 16 guests