Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Automatically load a match config on map load, and support for downloading workshop maps #153

Open
GekasD opened this issue Jan 24, 2024 · 0 comments

Comments

@GekasD
Copy link

GekasD commented Jan 24, 2024

Autoload config

A configuration that if set, loads a match config every time a map loads, if the match isn't already live obviously.

Get5 documentation reference of a ConVar that does the same thing: https://splewis.github.io/get5/latest/configuration/#get5_autoload_config

Workshop maps

Note on workshop maps for CS2, CS:GO used to have a startup parameter +workshop_start_map id it would download/update the workshop map on server start and also load it, but this has been removed in CS2, a clunky workaround I have found is to load an "empty" map (literally a map called <empty>), and then starting the workshop map with host_workshop_map id, so if you could maybe account for <empty> being loaded first (when trying to autoload a config, just return the method I guess).

Get5 reference on workshop maps (click on + of maplist property): https://splewis.github.io/get5/latest/match_schema/#schema

Possible improvement over get5:
Change the way maps are passed into the match config into cleaner JSON objects, so instead of passing map file names we can pass:

{
    "maplist": [
        { "name": "Dust II", "id": "de_dust2", "type": 0 },
        { "name": "Biome", "id": "3075706807", "type": 1 },
        { "name": "Thera", "id": "3121217565", "type": 1 }
    ]
}

map.type could be a C# enum, could also be a string instead of a number, this is just an example:

enum MapType {
    Official,
    Workshop
}

map.name can be used in chat messages and such.

The above improvement would make it easier for the plugin to tell if a map is a workshop map without needing to split strings like get5 did.

C# example of handling a map change

public static async Task ChangeMap(Map map, int delay = 3) {
	Server.PrintToChatAll($"Changing to map: {map.Name}");
	if (map.Type == MapType.Workshop) {
		Server.PrintToChatAll($"Warning: Since {map.Name} is a workshop map");
		Server.PrintToChatAll("The server might need to download / update the map");
	}

	await Task.Delay(delay * 1000);
		
	Server.NextFrame(() => {
		if (map.Type == MapType.Official) {
			Server.ExecuteCommand($"changelevel {map.Id}");
		} else {
			Server.ExecuteCommand($"host_workshop_map {map.Id}");
		}
	});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants