@@ -105,43 +105,36 @@ void LoadMapcycle()
105105public void MultiMode_OnMapCycleReloaded ()
106106{
107107 LoadMapcycle ();
108-
109- CreateTimer (0.5 , Timer_ReexecuteCommands , _ , TIMER_FLAG_NO_MAPCHANGE );
110- }
111108
112- public Action Timer_ReexecuteCommands (Handle timer )
113- {
114109 char currentMap [PLATFORM_MAX_PATH ];
115110 GetCurrentMap (currentMap , sizeof (currentMap ));
116-
111+
117112 char currentGroup [64 ];
118113 char currentSubGroup [64 ];
119114 MultiMode_GetCurrentGameMode (currentGroup , sizeof (currentGroup ), currentSubGroup , sizeof (currentSubGroup ));
120-
115+
121116 strcopy (g_sCurrentMap , sizeof (g_sCurrentMap ), currentMap );
122117 strcopy (g_sCurrentGroup , sizeof (g_sCurrentGroup ), currentGroup );
123118 strcopy (g_sCurrentSubGroup , sizeof (g_sCurrentSubGroup ), currentSubGroup );
124-
119+
125120 if (strlen (currentMap ) > 0 )
126121 {
127122 if (! g_bMapCommandsExecutedThisMap )
128123 {
129- MMC_WriteToLogFile (null , " [MultiMode MapCycle Commands] Mapcycle reloaded, executing commands for current map \" %s \" (group: %s , subgroup: %s )" ,
124+ MMC_WriteToLogFile (null , " [MultiMode MapCycle Commands] Mapcycle reloaded, executing commands for current map \" %s \" (group: %s , subgroup: %s )" ,
130125 currentMap , strlen (currentGroup ) > 0 ? currentGroup : " none" , strlen (currentSubGroup ) > 0 ? currentSubGroup : " none" );
131-
126+
132127 ExecuteMapCommand (g_sCurrentGroup , g_sCurrentSubGroup , g_sCurrentMap );
133128 g_bMapCommandsExecutedThisMap = true ;
134129 }
135- else if ( StrEqual ( currentMap , g_sCurrentMap ))
130+ else
136131 {
137- MMC_WriteToLogFile (null , " [MultiMode MapCycle Commands] Mapcycle reloaded after modification , re-executing commands for current map \" %s \" (group: %s , subgroup: %s )" ,
132+ MMC_WriteToLogFile (null , " [MultiMode MapCycle Commands] Mapcycle reloaded, re-executing commands for current map \" %s \" (group: %s , subgroup: %s )" ,
138133 currentMap , strlen (currentGroup ) > 0 ? currentGroup : " none" , strlen (currentSubGroup ) > 0 ? currentSubGroup : " none" );
139-
134+
140135 ExecuteMapCommand (g_sCurrentGroup , g_sCurrentSubGroup , g_sCurrentMap );
141136 }
142137 }
143-
144- return Plugin_Stop ;
145138}
146139
147140KeyValues GetMapcycle ()
@@ -204,23 +197,60 @@ void ExecuteMapCommand(const char[] gamemode, const char[] subgroup, const char[
204197 return ;
205198 }
206199
207- char command [512 ];
208- char config [PLATFORM_MAX_PATH ];
200+ KeyValues mapKv = null ;
201+ if (strlen (subgroup ) > 0 )
202+ mapKv = MMC_GetSubGroupMapKv (g_kvMapcycle , gamemode , subgroup , map );
203+ else
204+ mapKv = MMC_GetMapKv (g_kvMapcycle , gamemode , map );
209205
210- if (GetMapCycleKeyValue ( g_kvMapcycle , gamemode , subgroup , map , MAPCYCLE_KEY_COMMAND , command , sizeof ( command )) )
206+ if (mapKv != null )
211207 {
212- ServerCommand (" %s " , command );
213- MMC_WriteToLogFile (null , " [MultiMode MapCycle Commands] Executed command for map %s (group: %s , subgroup: %s ): %s " ,
214- map , gamemode , strlen (subgroup ) > 0 ? subgroup : " none" , command );
215- }
208+ char command [512 ];
209+ if (mapKv .GotoFirstSubKey (false ))
210+ {
211+ do
212+ {
213+ char keyName [64 ];
214+ mapKv .GetSectionName (keyName , sizeof (keyName ));
215+ if (StrEqual (keyName , MAPCYCLE_KEY_COMMAND ))
216+ {
217+ mapKv .GetString (NULL_STRING , command , sizeof (command ), " " );
218+ if (strlen (command ) > 0 )
219+ {
220+ ServerCommand (" %s " , command );
221+ MMC_WriteToLogFile (null , " [MultiMode MapCycle Commands] Executed command for map %s (group: %s , subgroup: %s ): %s " ,
222+ map , gamemode , strlen (subgroup ) > 0 ? subgroup : " none" , command );
223+ }
224+ }
225+ } while (mapKv .GotoNextKey (false ));
226+ mapKv .GoBack ();
227+ }
228+ mapKv .Rewind ();
216229
217- if (GetMapCycleKeyValue (g_kvMapcycle , gamemode , subgroup , map , MAPCYCLE_KEY_CONFIG , config , sizeof (config )))
230+ char config [PLATFORM_MAX_PATH ];
231+ mapKv .GetString (MAPCYCLE_KEY_CONFIG , config , sizeof (config ), " " );
232+ delete mapKv ;
233+
234+ if (strlen (config ) > 0 )
235+ {
236+ char configPath [PLATFORM_MAX_PATH ];
237+ Format (configPath , sizeof (configPath ), " cfg/%s " , config );
238+ ServerCommand (" exec \" %s \" " , configPath );
239+ MMC_WriteToLogFile (null , " [MultiMode MapCycle Commands] Executed config for map %s (group: %s , subgroup: %s ): %s " ,
240+ map , gamemode , strlen (subgroup ) > 0 ? subgroup : " none" , config );
241+ }
242+ }
243+ else
218244 {
219- char configPath [PLATFORM_MAX_PATH ];
220- Format (configPath , sizeof (configPath ), " cfg/%s " , config );
221- ServerCommand (" exec \" %s \" " , configPath );
222- MMC_WriteToLogFile (null , " [MultiMode MapCycle Commands] Executed config for map %s (group: %s , subgroup: %s ): %s " ,
223- map , gamemode , strlen (subgroup ) > 0 ? subgroup : " none" , config );
245+ char config [PLATFORM_MAX_PATH ];
246+ if (GetMapCycleKeyValue (g_kvMapcycle , gamemode , subgroup , map , MAPCYCLE_KEY_CONFIG , config , sizeof (config )))
247+ {
248+ char configPath [PLATFORM_MAX_PATH ];
249+ Format (configPath , sizeof (configPath ), " cfg/%s " , config );
250+ ServerCommand (" exec \" %s \" " , configPath );
251+ MMC_WriteToLogFile (null , " [MultiMode MapCycle Commands] Executed config for map %s (group: %s , subgroup: %s ): %s " ,
252+ map , gamemode , strlen (subgroup ) > 0 ? subgroup : " none" , config );
253+ }
224254 }
225255}
226256
0 commit comments