Skip to content

Commit

Permalink
0.7.5 | BO2 and CFGs fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shobhit-pathak committed Apr 27, 2024
1 parent 2116cc8 commit 133454d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 15 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
19 changes: 14 additions & 5 deletions MatchManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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,
Expand All @@ -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, () => {
Expand Down
18 changes: 10 additions & 8 deletions MatchZy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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/)";

Expand Down Expand Up @@ -287,13 +287,15 @@ public partial class MatchZy : BasePlugin
// });

RegisterListener<Listeners.OnMapStart>(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<Listeners.OnMapEnd>(() => {
Expand Down
2 changes: 1 addition & 1 deletion MatchZy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.215">
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.217">
<PrivateAssets>none</PrivateAssets>
<ExcludeAssets>runtime</ExcludeAssets>
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
6 changes: 5 additions & 1 deletion Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 133454d

Please sign in to comment.