From aaecc7d9fe59cfbe6973f7cd6b6b102b8f0d93d6 Mon Sep 17 00:00:00 2001 From: Shobhit Pathak Date: Tue, 27 Aug 2024 20:04:38 +0530 Subject: [PATCH 1/3] 0.8.5: start message, hostname and coach fix --- CHANGELOG.md | 8 ++++++++ Coach.cs | 8 +++++--- ConfigConvars.cs | 2 ++ MatchZy.cs | 2 +- Utility.cs | 13 +++++++++++-- cfg/MatchZy/config.cfg | 6 ++++++ documentation/docs/configuration.md | 4 ++++ 7 files changed, 37 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae9fc89..534d84d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # 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 "" + # 0.8.4 #### August 27, 2024 diff --git a/Coach.cs b/Coach.cs index 1876a2e..5f5f55a 100644 --- a/Coach.cs +++ b/Coach.cs @@ -72,10 +72,11 @@ public void HandleCoaches() { coachKillTimer?.Kill(); coachKillTimer = null; + HashSet coaches = GetAllCoaches(); + if (coaches.Count == 0) return; int freezeTime = ConVar.Find("mp_freezetime")!.GetPrimitiveValue(); freezeTime = freezeTime > 2 ? freezeTime: 2; coachKillTimer ??= AddTimer(freezeTime - 1.5f, KillCoaches); - HashSet coaches = GetAllCoaches(); HashSet competitiveSpawnCoaches = new(); if (spawnsData.Values.Any(list => list.Count == 0)) GetSpawns(); @@ -203,12 +204,13 @@ private void KillCoaches() { if (isPaused || IsTacticalTimeoutActive()) return; HashSet 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, () => @@ -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};"); }); } } \ No newline at end of file diff --git a/ConfigConvars.cs b/ConfigConvars.cs index f44c6da..7d487d8 100644 --- a/ConfigConvars.cs +++ b/ConfigConvars.cs @@ -27,6 +27,8 @@ public partial class MatchZy public FakeConVar 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 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) { diff --git a/MatchZy.cs b/MatchZy.cs index 57468c4..eaf0a93 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.8.4"; + public override string ModuleVersion => "0.8.5"; public override string ModuleAuthor => "WD- (https://github.com/shobhit-pathak/)"; diff --git a/Utility.cs b/Utility.cs index 8662383..237c2fd 100644 --- a/Utility.cs +++ b/Utility.cs @@ -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() != "") + { + List matchStartMessages = [.. matchStartMessage.Value.Split("$$$")]; + foreach (string message in matchStartMessages) + { + PrintToAllChat(GetColorTreatedString(FormatCvarValue(message.Trim()))); + } + } } public void HandleClanTags() @@ -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}"); } diff --git a/cfg/MatchZy/config.cfg b/cfg/MatchZy/config.cfg index 17fea48..f8fc245 100644 --- a/cfg/MatchZy/config.cfg +++ b/cfg/MatchZy/config.cfg @@ -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 "" diff --git a/documentation/docs/configuration.md b/documentation/docs/configuration.md index 30d6274..3af62b5 100644 --- a/documentation/docs/configuration.md +++ b/documentation/docs/configuration.md @@ -126,6 +126,10 @@ Example: `matchzy_demo_upload_url "https://your-website.com/upload-endpoint"` **`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} +
**`Default: ""`** + ####`matchzy_loadbackup` : Loads a match backup from the given file. Relative to `csgo/MatchZyDataBackup/`. From a705973f190c6cde5880a2a6dd0f76691bdea6e7 Mon Sep 17 00:00:00 2001 From: Shobhit Pathak Date: Tue, 27 Aug 2024 22:15:29 +0530 Subject: [PATCH 2/3] 0.8.5: start message, hostname and coach fix --- Utility.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Utility.cs b/Utility.cs index 237c2fd..ec4783b 100644 --- a/Utility.cs +++ b/Utility.cs @@ -771,7 +771,7 @@ private void HandleMatchStart() { Server.PrintToChatAll($"{chatPrefix} {ChatColors.Green}MatchZy{ChatColors.Default} Plugin by {ChatColors.Green}WD-{ChatColors.Default}"); } - if (matchStartMessage.Value.Trim() != "") + if (matchStartMessage.Value.Trim() != "" && matchStartMessage.Value.Trim() != "\"\"") { List matchStartMessages = [.. matchStartMessage.Value.Split("$$$")]; foreach (string message in matchStartMessages) @@ -1037,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 { From 3d1ddc1809d31114eca27b590fdd4ceddc9d92c1 Mon Sep 17 00:00:00 2001 From: Shobhit Pathak Date: Tue, 27 Aug 2024 22:17:51 +0530 Subject: [PATCH 3/3] 0.8.5: start message, hostname and coach fix --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 534d84d..0b7f087 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - 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