@@ -188,6 +188,53 @@ bool GetMapCycleKeyValue(KeyValues kv, const char[] gamemode, const char[] subgr
188188 return false ;
189189}
190190
191+ void ExecuteSubgroupCommandsAndConfig (const char [] gamemode , const char [] subgroup , const char [] map )
192+ {
193+ g_kvMapcycle .Rewind ();
194+ if (! g_kvMapcycle .JumpToKey (gamemode ) || ! g_kvMapcycle .JumpToKey (" subgroup" ) || ! g_kvMapcycle .JumpToKey (subgroup ))
195+ {
196+ g_kvMapcycle .Rewind ();
197+ return ;
198+ }
199+
200+ char command [512 ];
201+ if (g_kvMapcycle .GotoFirstSubKey (false ))
202+ {
203+ do
204+ {
205+ char keyName [64 ];
206+ g_kvMapcycle .GetSectionName (keyName , sizeof (keyName ));
207+ if (StrEqual (keyName , MAPCYCLE_KEY_COMMAND ))
208+ {
209+ g_kvMapcycle .GetString (NULL_STRING , command , sizeof (command ), " " );
210+ if (strlen (command ) > 0 )
211+ {
212+ ServerCommand (" %s " , command );
213+ MMC_WriteToLogFile (null , " [MultiMode MapCycle Commands] Executed subgroup command for map %s (group: %s , subgroup: %s ): %s " ,
214+ map , gamemode , subgroup , command );
215+ }
216+ }
217+ } while (g_kvMapcycle .GotoNextKey (false ));
218+ g_kvMapcycle .GoBack ();
219+ }
220+
221+ char config [PLATFORM_MAX_PATH ];
222+ g_kvMapcycle .GetString (MAPCYCLE_KEY_CONFIG , config , sizeof (config ), " " );
223+ if (strlen (config ) > 0 )
224+ {
225+ char configPath [PLATFORM_MAX_PATH ];
226+ Format (configPath , sizeof (configPath ), " cfg/%s " , config );
227+ ServerCommand (" exec \" %s \" " , configPath );
228+ MMC_WriteToLogFile (null , " [MultiMode MapCycle Commands] Executed subgroup config for map %s (group: %s , subgroup: %s ): %s " ,
229+ map , gamemode , subgroup , config );
230+ }
231+
232+ g_kvMapcycle .GoBack ();
233+ g_kvMapcycle .GoBack ();
234+ g_kvMapcycle .GoBack ();
235+ g_kvMapcycle .Rewind ();
236+ }
237+
191238void ExecuteMapCommand (const char [] gamemode , const char [] subgroup , const char [] map )
192239{
193240 if (g_kvMapcycle == null )
@@ -197,6 +244,9 @@ void ExecuteMapCommand(const char[] gamemode, const char[] subgroup, const char[
197244 return ;
198245 }
199246
247+ if (strlen (subgroup ) > 0 )
248+ ExecuteSubgroupCommandsAndConfig (gamemode , subgroup , map );
249+
200250 KeyValues mapKv = null ;
201251 if (strlen (subgroup ) > 0 )
202252 mapKv = MMC_GetSubGroupMapKv (g_kvMapcycle , gamemode , subgroup , map );
0 commit comments