public override async Task PlaytestTwentyMinuteTask(RconService rconService, SrcdsLogService srcdsLogService) { await base.PlaytestTwentyMinuteTask(rconService, srcdsLogService); if (_dataService.RSettings.ProgramSettings.Debug) { _ = _log.LogMessage("CSGO class PlaytestTwentyMinuteTask", false, color: LOG_COLOR); } var wsId = GeneralUtil.GetWorkshopIdFromFqdn(WorkshopLink.ToString()); await rconService.RconCommand(ServerLocation, $"host_workshop_map {wsId}"); if (!IsCasual) { //Delay before setting password again. await Task.Delay(15000); await rconService.RconCommand(ServerLocation, $"sv_password {CompPassword}"); } //Run a loop to validate that the level has actually changed. _ = Task.Run(async() => { var tries = 0; //Loop until timeout, or success while (tries < 10) { //Wait before retry await Task.Delay(30 * 1000); var runningLevel = await rconService.GetRunningLevelAsync(ServerLocation); if (runningLevel != null && runningLevel.Length == 3 && runningLevel[1] == wsId) { break; } tries++; await _log.LogMessage($"Level not set after {tries} attempts. Trying again.", color: LOG_COLOR); await rconService.RconCommand(ServerLocation, $"host_workshop_map {wsId}"); } if (tries <= 10) { await _log.LogMessage($"Level changed after {tries} attempts!", color: LOG_COLOR); } else { await _log.LogMessage($"Failed to change level after {tries} attempts!", color: LOG_COLOR); } }); }