Skip to content

Commit

Permalink
Merge pull request #219 from shobhit-pathak/dev
Browse files Browse the repository at this point in the history
0.8.5
  • Loading branch information
shobhit-pathak authored Aug 27, 2024
2 parents 56e9ca4 + 3d1ddc1 commit 87420fb
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 7 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# MatchZy Changelog

# 0.8.5

#### August 27, 2024

- Added `matchzy_match_start_message` convar to configure message to show when the match starts. Use $$$ to break message into multiple lines.
- Some improvements and guard checks in coach system
- Fixed `matchzy_hostname_format` not getting disabled on setting its value to ""
- Fixed winner side in `round_end` event

# 0.8.4

#### August 27, 2024
Expand Down
8 changes: 5 additions & 3 deletions Coach.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ public void HandleCoaches()
{
coachKillTimer?.Kill();
coachKillTimer = null;
HashSet<CCSPlayerController> coaches = GetAllCoaches();
if (coaches.Count == 0) return;
int freezeTime = ConVar.Find("mp_freezetime")!.GetPrimitiveValue<int>();
freezeTime = freezeTime > 2 ? freezeTime: 2;
coachKillTimer ??= AddTimer(freezeTime - 1.5f, KillCoaches);
HashSet<CCSPlayerController> coaches = GetAllCoaches();
HashSet<CCSPlayerController> competitiveSpawnCoaches = new();
if (spawnsData.Values.Any(list => list.Count == 0)) GetSpawns();

Expand Down Expand Up @@ -203,12 +204,13 @@ private void KillCoaches()
{
if (isPaused || IsTacticalTimeoutActive()) return;
HashSet<CCSPlayerController> coaches = GetAllCoaches();
if (coaches.Count == 0) return;
string suicidePenalty = GetConvarStringValue(ConVar.Find("mp_suicide_penalty"));
string deathDropGunEnabled = GetConvarStringValue(ConVar.Find("mp_death_drop_gun"));
string specFreezeTime = GetConvarStringValue(ConVar.Find("spec_freeze_time"));
string specFreezeTimeLock = GetConvarStringValue(ConVar.Find("spec_freeze_time_lock"));
string specFreezeDeathanim = GetConvarStringValue(ConVar.Find("spec_freeze_deathanim_time"));
Server.ExecuteCommand("mp_suicide_penalty 0; mp_death_drop_gun 0;spec_freeze_time 0; spec_freeze_time_lock 0; spec_freeze_deathanim_time 0;");
Server.ExecuteCommand("mp_suicide_penalty 0;spec_freeze_time 0; spec_freeze_time_lock 0; spec_freeze_deathanim_time 0;");

// Adding timer to make sure above commands are executed successfully.
AddTimer(0.5f, () =>
Expand All @@ -224,7 +226,7 @@ private void KillCoaches()
DropWeaponByDesignerName(coach, "weapon_c4");
coach.PlayerPawn.Value!.CommitSuicide(explode: false, force: true);
}
Server.ExecuteCommand($"mp_suicide_penalty {suicidePenalty}; mp_death_drop_gun {deathDropGunEnabled}; spec_freeze_time {specFreezeTime}; spec_freeze_time_lock {specFreezeTimeLock}; spec_freeze_deathanim_time {specFreezeDeathanim};");
Server.ExecuteCommand($"mp_suicide_penalty {suicidePenalty}; spec_freeze_time {specFreezeTime}; spec_freeze_time_lock {specFreezeTimeLock}; spec_freeze_deathanim_time {specFreezeDeathanim};");
});
}
}
2 changes: 2 additions & 0 deletions ConfigConvars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public partial class MatchZy

public FakeConVar<bool> stopCommandNoDamage = new("matchzy_stop_command_no_damage", "Whether the stop command becomes unavailable if a player damages a player from the opposing team.", false);

public FakeConVar<string> matchStartMessage = new("matchzy_match_start_message", "Message to show when the match starts. Use $$$ to break message into multiple lines. Set to \"\" to disable.", "");

[ConsoleCommand("matchzy_whitelist_enabled_default", "Whether Whitelist is enabled by default or not. Default value: false")]
public void MatchZyWLConvar(CCSPlayerController? player, CommandInfo command)
{
Expand Down
2 changes: 1 addition & 1 deletion 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.8.4";
public override string ModuleVersion => "0.8.5";

public override string ModuleAuthor => "WD- (https://github.com/shobhit-pathak/)";

Expand Down
15 changes: 12 additions & 3 deletions Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,14 @@ private void HandleMatchStart()
{
Server.PrintToChatAll($"{chatPrefix} {ChatColors.Green}MatchZy{ChatColors.Default} Plugin by {ChatColors.Green}WD-{ChatColors.Default}");
}
if (matchStartMessage.Value.Trim() != "" && matchStartMessage.Value.Trim() != "\"\"")
{
List<string> matchStartMessages = [.. matchStartMessage.Value.Split("$$$")];
foreach (string message in matchStartMessages)
{
PrintToAllChat(GetColorTreatedString(FormatCvarValue(message.Trim())));
}
}
}

public void HandleClanTags()
Expand Down Expand Up @@ -1029,7 +1037,7 @@ private void HandlePostRoundEndEvent(EventRoundEnd @event)
long matchId = liveMatchId;
int ctTeamNum = reverseTeamSides["CT"] == matchzyTeam1 ? 1 : 2;
int tTeamNum = reverseTeamSides["TERRORIST"] == matchzyTeam1 ? 1 : 2;
Winner winner = new(@event.Winner == 3 ? ctTeamNum.ToString() : tTeamNum.ToString(), t1score > t2score ? "team1" : "team2");
Winner winner = new(@event.Winner.ToString(), t1score > t2score ? "team1" : "team2");

var roundEndEvent = new MatchZyRoundEndedEvent
{
Expand Down Expand Up @@ -1526,8 +1534,9 @@ public string FormatCvarValue(string value)

public void UpdateHostname()
{
if (hostnameFormat.Value.Trim() == "") return;
string formattedHostname = FormatCvarValue(hostnameFormat.Value);
string hostname = hostnameFormat.Value.Trim();
if (hostname == "" || hostname == "\"\"") return;
string formattedHostname = FormatCvarValue(hostname);
Log($"UPDATING HOSTNAME TO: {formattedHostname}");
Server.ExecuteCommand($"hostname {formattedHostname}");
}
Expand Down
6 changes: 6 additions & 0 deletions cfg/MatchZy/config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,9 @@ matchzy_hostname_format "MatchZy | {TEAM1} vs {TEAM2}"

// Whether to show damage report after each round or not. Default: true.
matchzy_enable_damage_report true

// Message to show when the match starts. Use $$$ to break message into multiple lines. Set to "" to disable.
// Available variables: {TIME}, {MATCH_ID}, {MAP}, {MAPNUMBER}, {TEAM1}, {TEAM2}, {TEAM1_SCORE}, {TEAM2_SCORE}
// Available Colors: {Default}, {Darkred}, {Green}, {LightYellow}, {LightBlue}, {Olive}, {Lime}, {Red}, {Purple}, {Grey}, {Yellow}, {Gold}, {Silver}, {Blue}, {DarkBlue}
// Example: {Green} Welcome to the server! {Default} $$$ Agent models are not allowed and may lead to {Red}disqualification!{Default}
matchzy_match_start_message ""
4 changes: 4 additions & 0 deletions documentation/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ Example: `matchzy_demo_upload_url "https://your-website.com/upload-endpoint"` <b
####`matchzy_hostname_format`
: The server hostname to use. Set to "" to disable/use existing. Available variables: {TIME}, {MATCH_ID}, {MAP}, {MAPNUMBER}, {TEAM1}, {TEAM2}, {TEAM1_SCORE}, {TEAM2_SCORE}<br>**`Default: MatchZy | {TEAM1} vs {TEAM2}`**

####`matchzy_match_start_message`
: Message to show when the match starts. Use $$$ to break message into multiple lines. Set to "" to disable. Available Colors: {Default}, {Darkred}, {Green}, {LightYellow}, {LightBlue}, {Olive}, {Lime}, {Red}, {Purple}, {Grey}, {Yellow}, {Gold}, {Silver}, {Blue}, {DarkBlue}. Example usage: matchzy_match_start_message {Green} Welcome to the server! {Default} $$$ Agent models are not allowed and may lead to {Red}disqualification!{Default}
<br>**`Default: ""`**

####`matchzy_loadbackup`
: Loads a match backup from the given file. Relative to `csgo/MatchZyDataBackup/`.

Expand Down

0 comments on commit 87420fb

Please sign in to comment.