Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,30 @@

A MetaMod plugin that allows you to use multiple workshop addons at once and have clients download them.

## Commands
## ConVars
- `mm_extra_addons <ids>` The workshop IDs of extra addons separated by commas, addons will be downloaded (if not present) and mounted (e.g. "3090239773,3070231528").
Once downloads are done, the map is automatically reloaded so content can be precached.
- `mm_client_extra_addons <ids>` The workshop IDs of extra client-side only addons that will be loaded by all clients, separated by commas. These addons are not loaded or downloaded by the server.
Changes will only apply to future clients.

- `mm_extra_addons_timeout <seconds> (default 10)` How long until clients are timed out in between connects for extra addons, timed out clients will reconnect for their current pending download.
- `mm_print_searchpaths` Print all the search paths currently mounted by the server.
- `mm_addon_mount_download <0/1> (default 0)` If enabled, the plugin will initiate an addon download every time even if it's already installed, this will guarantee that updates are applied immediately.
- `mm_cache_clients_with_addons <0/1> (default 0)` If enabled, the plugin will keep track of client SteamIDs that have fully joined to prevent sending them addons when they already have them (i.e. when they rejoin or the map changes).
- `mm_cache_clients_with_addons <0/1> (default 0)` If enabled, the plugin will keep track of which addons client SteamIDs have downloaded to prevent sending them addons when they already have them (i.e. when they rejoin or the map changes).
- `mm_cache_clients_duration <0/seconds> (default 0)` How long to cache clients' downloaded addons list, pass 0 for forever.
- `mm_block_disconnect_messages <0/1> (default 0)` If enabled, the plugin will block *ALL* disconnect events with the "loop shutdown" reason. This will prevent disconnect chat messsages whenever someone reconnects because they're getting an addon.

## Commands
- `mm_download_addon <id>` Download an addon manually.

Both of these commands require a map reload to apply changes.
- `mm_add_addon <id>` Add an addon to the list, but don't mount.
- `mm_remove_addon <id>` Remove an addon from the list, but don't unmount.

These following commands will only affect future clients:
- `mm_add_client_addon <id>` Add a workshop ID to the global client-only addon list.
- `mm_remove_client_addon <id>` Remove a workshop ID from the global client-only addon list.

## Usage in other MetaMod plugins
- Include the [public header](https://github.com/Source2ZE/MultiAddonManager/blob/main/public/imultiaddonmanager.h).
- Query the interface in `AllPluginsLoaded` like this:
Expand Down
6 changes: 4 additions & 2 deletions cfg/multiaddonmanager/multiaddonmanager.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Extra addon settings, this is only executed once on plugin load
mm_extra_addons "" // The workshop IDs of extra addons, separated by commas (e.g. "3090239773,3070231528")
mm_extra_addons_timeout 10 // How long until clients are timed out in between connects for extra addons, requires mm_extra_addons to be used
mm_client_extra_addons "" // The workshop IDs of extra client addons that will be applied to all clients, separated by commas
mm_extra_addons_timeout 10 // How long until clients are timed out in between connects for extra addons in seconds, requires mm_extra_addons to be used
mm_addon_mount_download 0 // Whether to download an addon upon mounting even if it's installed
mm_cache_clients_with_addons 0 // Whether to cache clients who downloaded all addons, this will prevent reconnects on mapchange/rejoin
mm_cache_clients_with_addons 0 // Whether to cache clients addon download list, this will prevent reconnects on mapchange/rejoin
mm_cache_clients_duration 0 // How long to cache clients' downloaded addons list in seconds, pass 0 for forever.
mm_block_disconnect_messages 0 // Whether to block "loop shutdown" disconnect messages
24 changes: 17 additions & 7 deletions public/imultiaddonmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@

#pragma once

#define MULTIADDONMANAGER_INTERFACE "MultiAddonManager002"

#define MULTIADDONMANAGER_INTERFACE "MultiAddonManager003"
class IMultiAddonManager
{
public:
// These add/remove to the internal list without reloading anything
// pszWorkshopID is the workshop ID in string form (e.g. "3157463861")
virtual bool AddAddon(const char *pszWorkshopID) = 0;
virtual bool RemoveAddon(const char *pszWorkshopID) = 0;
virtual bool AddAddon(const char *pszWorkshopID, bool bRefresh = false) = 0;
virtual bool RemoveAddon(const char *pszWorkshopID, bool bRefresh = false) = 0;

// Returns true if the given addon is mounted in the filesystem
virtual bool IsAddonMounted(const char *pszWorkshopID) = 0;
// Returns true if the given addon is mounted in the filesystem.
// Pass 'true' to bCheckWorkshopMap to check from the server mounted workshop map as well.
virtual bool IsAddonMounted(const char *pszWorkshopID, bool bCheckWorkshopMap = false) = 0;

// Start an addon download of the given workshop ID
// Returns true if the download successfully started or the addon already exists, and false otherwise
Expand All @@ -40,8 +40,18 @@ class IMultiAddonManager

// Refresh addons, applying any changes from add/remove
// This will trigger a map reload once all addons are updated and mounted
virtual void RefreshAddons() = 0;
virtual void RefreshAddons(bool bReloadMap = false) = 0;

// Clear the internal list and unmount all addons excluding the current workshop map
virtual void ClearAddons() = 0;

// Check whether the server is connected to the game coordinator, and therefore is capable of downloading addons.
// Should be called before calling DownloadAddon.
virtual bool HasUGCConnection() = 0;

// Functions to manage addons to be loaded only by a client.
// Pass a steamID value of 0 to perform the operation on a global list instead, and bRefresh to 'true' to trigger a reconnect if necessary.
virtual void AddClientAddon(const char *pszAddon, uint64 steamID64 = 0, bool bRefresh = false) = 0;
virtual void RemoveClientAddon(const char *pszAddon, uint64 steamID64 = 0) = 0;
virtual void ClearClientAddons(uint64 steamID64 = 0) = 0;
};
Loading