diff --git a/cstrike/cfg/sourcemod/zombiereloaded/classic.cfg b/cstrike/cfg/sourcemod/zombiereloaded/classic.cfg new file mode 100644 index 0000000..46f75ce --- /dev/null +++ b/cstrike/cfg/sourcemod/zombiereloaded/classic.cfg @@ -0,0 +1,5 @@ +// Dummy config that's not doing anything so classic settings will be kept. It's +// still possible to add stuff here for configuring classic mode if something +// differ from the default configuration. + +// Used by randommode.cfg. diff --git a/cstrike/cfg/sourcemod/zombiereloaded/gamemode-examples/cs_italy.cfg b/cstrike/cfg/sourcemod/zombiereloaded/gamemode-examples/cs_italy.cfg index f3ff255..d0e385c 100644 --- a/cstrike/cfg/sourcemod/zombiereloaded/gamemode-examples/cs_italy.cfg +++ b/cstrike/cfg/sourcemod/zombiereloaded/gamemode-examples/cs_italy.cfg @@ -1,4 +1,4 @@ // Place this in cfg/sourcemod/zombiereloaded to use it. -// Use survivor mode in cs_italy. -exec sourcemod/zombiereloaded/survivor.cfg +// Enable a random mode in cs_italy. +exec sourcemod/zombiereloaded/randommode.cfg diff --git a/cstrike/cfg/sourcemod/zombiereloaded/randommode.cfg b/cstrike/cfg/sourcemod/zombiereloaded/randommode.cfg new file mode 100644 index 0000000..50bdee0 --- /dev/null +++ b/cstrike/cfg/sourcemod/zombiereloaded/randommode.cfg @@ -0,0 +1,7 @@ +cfglist_create zr_modes +cfglist_add zr_modes sourcemod/zombiereloaded/classic.cfg +cfglist_add zr_modes sourcemod/zombiereloaded/nemesis.cfg +cfglist_add zr_modes sourcemod/zombiereloaded/survivor.cfg +cfglist_add zr_modes sourcemod/zombiereloaded/swarm.cfg +cfglist_exec_random zr_modes +cfglist_delete zr_modes diff --git a/cstrike/cfg/sourcemod/zombiereloaded/swarm.cfg b/cstrike/cfg/sourcemod/zombiereloaded/swarm.cfg index 3d25d65..421f744 100644 --- a/cstrike/cfg/sourcemod/zombiereloaded/swarm.cfg +++ b/cstrike/cfg/sourcemod/zombiereloaded/swarm.cfg @@ -23,3 +23,9 @@ zr_infect_mzombie_respawn 1 // Disable respawning. zr_respawn 0 zr_zspawn 0 + +// Use the ConfigList plugin to post execute swarm.post.cfg. ZR will detect this +// plugin and execute the "zr_post_exec" list if it exists. +cfglist_delete zr_post_exec +cfglist_create zr_post_exec +cfglist_add zr_post_exec sourcemod/zombiereloaded/swarm.post.cfg diff --git a/src/zombiereloaded.sp b/src/zombiereloaded.sp index c239389..08b8c5f 100644 --- a/src/zombiereloaded.sp +++ b/src/zombiereloaded.sp @@ -174,6 +174,24 @@ public OnAllPluginsLoaded() { // Forward event to modules. WeaponsOnAllPluginsLoaded(); + ConfigOnAllPluginsLoaded(); +} + +/** + * A library was added. + */ +public OnLibraryAdded(const String:name[]) +{ + // Forward event to modules. + ConfigOnLibraryAdded(name); +} + +/** + * A library was removed. + */ +public OnLibraryRemoved(const String:name[]) +{ + ConfigOnLibraryRemoved(name); } /** diff --git a/src/zr/config.inc b/src/zr/config.inc index f11418a..f27c5b1 100644 --- a/src/zr/config.inc +++ b/src/zr/config.inc @@ -170,6 +170,11 @@ enum ConfigData */ new g_ConfigData[ConfigFile][ConfigData]; +/** + * Stores status of the optional ConfigList plugin. + */ +new bool:g_ConfigListAvailable = false; + /** * Actions to use when working on key/values. */ @@ -250,6 +255,14 @@ ConfigOnModulesLoaded() return; } + // Check if ConfigList is available. + if (g_ConfigListAvailable) + { + // Execute the zr_post_exec list before the map config file. This list + // may not exist, but that's ok. + ServerCommand("cfglist_exec_list zr_post_exec"); + } + // Execute config file. ServerCommand("exec %s", mapconfig); @@ -257,6 +270,38 @@ ConfigOnModulesLoaded() LogEvent(false, LogType_Normal, LOG_CORE_EVENTS, LogModule_Config, "Post Map Configs", "Executed post map config file: %s", path); } +/** + * All plugins have finished loading. + */ +ConfigOnAllPluginsLoaded() +{ + g_ConfigListAvailable = LibraryExists("configlist"); +} + +/** + * A library was added. + */ +ConfigOnLibraryAdded(const String:name[]) +{ + if (StrEqual(name, "configlist")) + { + // ConfigList loaded. + g_ConfigListAvailable = true; + } +} + +/** + * A library was removed. + */ +ConfigOnLibraryRemoved(const String:name[]) +{ + if (StrEqual(name, "configlist")) + { + // ConfigList was unloaded. + g_ConfigListAvailable = false; + } +} + /** * Used by modules that rely on configs to register their config file info. * (Don't forget to set 'loaded' to 'true' (ConfigSetConfigLoaded) in config load function)