From 133454d2184c4d5dfbcc7e85140f303597f10a8f Mon Sep 17 00:00:00 2001 From: Shobhit Pathak Date: Sat, 27 Apr 2024 22:55:09 +0530 Subject: [PATCH] 0.7.5 | BO2 and CFGs fix --- CHANGELOG.md | 8 ++++++++ MatchManagement.cs | 19 ++++++++++++++----- MatchZy.cs | 18 ++++++++++-------- MatchZy.csproj | 2 +- Utility.cs | 6 +++++- 5 files changed, 38 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e2b3f5..8b2315f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # MatchZy Changelog +# 0.7.5 + +#### April 27, 2024 + +- Upgraded CounterStrikeSharp to v217 +- Fixed CFG execution on Map Start (After the latest update, CFGs were getting overriden by gamemodes cfg. Hence, added a timer to delay MatchZy's CFG execution on MapStart) +- Fixed BO2 setup, now Get5 server will be freed once the BO2 match is over + # 0.7.4 #### April 26, 2024 diff --git a/MatchManagement.cs b/MatchManagement.cs index c12ee31..4d4dce0 100644 --- a/MatchManagement.cs +++ b/MatchManagement.cs @@ -38,7 +38,7 @@ public partial class MatchZy HandleTeamNameChangeCommand(player, command.ArgString, 1); } - [ConsoleCommand("css_team2", "Sets team name for team1")] + [ConsoleCommand("css_team2", "Sets team name for team2")] public void OnTeam2Command(CCSPlayerController? player, CommandInfo command) { HandleTeamNameChangeCommand(player, command.ArgString, 2); } @@ -560,15 +560,24 @@ private CsTeam GetPlayerTeam(CCSPlayerController player) return playerTeam; } - public void EndSeries(string winnerName, int restartDelay) + public void EndSeries(string? winnerName, int restartDelay) { - Server.PrintToChatAll($"{chatPrefix} {ChatColors.Green}{winnerName}{ChatColors.Default} has won the match"); + if (winnerName == null) + { + PrintToAllChat($"{ChatColors.Green}{matchzyTeam1.teamName}{ChatColors.Default} and {ChatColors.Green}{matchzyTeam2.teamName}{ChatColors.Default} have tied the match"); + } + else + { + Server.PrintToChatAll($"{chatPrefix} {ChatColors.Green}{winnerName}{ChatColors.Default} has won the match"); + } + + string winnerTeam = (winnerName == null) ? "none" : matchzyTeam1.seriesScore > matchzyTeam2.seriesScore ? "team1" : "team2"; (int t1score, int t2score) = GetTeamsScore(); var seriesResultEvent = new MatchZySeriesResultEvent() { MatchId = liveMatchId.ToString(), - Winner = new Winner(t1score > t2score && reverseTeamSides["CT"] == matchzyTeam1 ? "3" : "2", matchzyTeam1.seriesScore > matchzyTeam2.seriesScore ? "team1" : "team2"), + Winner = new Winner(t1score > t2score && reverseTeamSides["CT"] == matchzyTeam1 ? "3" : "2", winnerTeam), Team1SeriesScore = matchzyTeam1.seriesScore, Team2SeriesScore = matchzyTeam2.seriesScore, TimeUntilRestore = 10, @@ -578,7 +587,7 @@ public void EndSeries(string winnerName, int restartDelay) await Task.Delay(2000); await SendEventAsync(seriesResultEvent); }); - database.SetMatchEndData(liveMatchId, winnerName, matchzyTeam1.seriesScore, matchzyTeam2.seriesScore); + database.SetMatchEndData(liveMatchId, winnerName ?? "Draw", matchzyTeam1.seriesScore, matchzyTeam2.seriesScore); if (resetCvarsOnSeriesEnd) ResetChangedConvars(); isMatchLive = false; AddTimer(restartDelay, () => { diff --git a/MatchZy.cs b/MatchZy.cs index 08cbb68..f27ba83 100644 --- a/MatchZy.cs +++ b/MatchZy.cs @@ -13,7 +13,7 @@ public partial class MatchZy : BasePlugin { public override string ModuleName => "MatchZy"; - public override string ModuleVersion => "0.7.4"; + public override string ModuleVersion => "0.7.5"; public override string ModuleAuthor => "WD- (https://github.com/shobhit-pathak/)"; @@ -287,13 +287,15 @@ public partial class MatchZy : BasePlugin // }); RegisterListener(mapName => { - if (!isMatchSetup) - { - AutoStart(); - return; - } - if (isWarmup) StartWarmup(); - if (isPractice) StartPracticeMode(); + AddTimer(1.0f, () => { + if (!isMatchSetup) + { + AutoStart(); + return; + } + if (isWarmup) StartWarmup(); + if (isPractice) StartPracticeMode(); + }); }); // RegisterListener(() => { diff --git a/MatchZy.csproj b/MatchZy.csproj index 7c7d494..e3f5a91 100644 --- a/MatchZy.csproj +++ b/MatchZy.csproj @@ -7,7 +7,7 @@ - + none runtime compile; build; native; contentfiles; analyzers; buildtransitive diff --git a/Utility.cs b/Utility.cs index 9a19be6..9d7a478 100644 --- a/Utility.cs +++ b/Utility.cs @@ -726,7 +726,11 @@ private void HandleKnifeWinner(EventCsWinPanelRound @event) int remainingMaps = matchConfig.NumMaps - matchzyTeam1.seriesScore - matchzyTeam2.seriesScore; Log($"[HandleMatchEnd] MATCH ENDED, remainingMaps: {remainingMaps}, NumMaps: {matchConfig.NumMaps}, Team1SeriesScore: {matchzyTeam1.seriesScore}, Team2SeriesScore: {matchzyTeam2.seriesScore}"); - if (matchConfig.SeriesCanClinch) { + if (matchzyTeam1.seriesScore == matchzyTeam2.seriesScore && remainingMaps <= 0) + { + EndSeries(null, restartDelay - 1); + } + else if (matchConfig.SeriesCanClinch) { int mapsToWinSeries = (matchConfig.NumMaps / 2) + 1; if (matchzyTeam1.seriesScore == mapsToWinSeries) { EndSeries(winnerName, restartDelay - 1);