Skip to content

Commit 87420fb

Browse files
Merge pull request #219 from shobhit-pathak/dev
0.8.5
2 parents 56e9ca4 + 3d1ddc1 commit 87420fb

File tree

7 files changed

+39
-7
lines changed

7 files changed

+39
-7
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# MatchZy Changelog
22

3+
# 0.8.5
4+
5+
#### August 27, 2024
6+
7+
- Added `matchzy_match_start_message` convar to configure message to show when the match starts. Use $$$ to break message into multiple lines.
8+
- Some improvements and guard checks in coach system
9+
- Fixed `matchzy_hostname_format` not getting disabled on setting its value to ""
10+
- Fixed winner side in `round_end` event
11+
312
# 0.8.4
413

514
#### August 27, 2024

Coach.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,11 @@ public void HandleCoaches()
7272
{
7373
coachKillTimer?.Kill();
7474
coachKillTimer = null;
75+
HashSet<CCSPlayerController> coaches = GetAllCoaches();
76+
if (coaches.Count == 0) return;
7577
int freezeTime = ConVar.Find("mp_freezetime")!.GetPrimitiveValue<int>();
7678
freezeTime = freezeTime > 2 ? freezeTime: 2;
7779
coachKillTimer ??= AddTimer(freezeTime - 1.5f, KillCoaches);
78-
HashSet<CCSPlayerController> coaches = GetAllCoaches();
7980
HashSet<CCSPlayerController> competitiveSpawnCoaches = new();
8081
if (spawnsData.Values.Any(list => list.Count == 0)) GetSpawns();
8182

@@ -203,12 +204,13 @@ private void KillCoaches()
203204
{
204205
if (isPaused || IsTacticalTimeoutActive()) return;
205206
HashSet<CCSPlayerController> coaches = GetAllCoaches();
207+
if (coaches.Count == 0) return;
206208
string suicidePenalty = GetConvarStringValue(ConVar.Find("mp_suicide_penalty"));
207209
string deathDropGunEnabled = GetConvarStringValue(ConVar.Find("mp_death_drop_gun"));
208210
string specFreezeTime = GetConvarStringValue(ConVar.Find("spec_freeze_time"));
209211
string specFreezeTimeLock = GetConvarStringValue(ConVar.Find("spec_freeze_time_lock"));
210212
string specFreezeDeathanim = GetConvarStringValue(ConVar.Find("spec_freeze_deathanim_time"));
211-
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;");
213+
Server.ExecuteCommand("mp_suicide_penalty 0;spec_freeze_time 0; spec_freeze_time_lock 0; spec_freeze_deathanim_time 0;");
212214

213215
// Adding timer to make sure above commands are executed successfully.
214216
AddTimer(0.5f, () =>
@@ -224,7 +226,7 @@ private void KillCoaches()
224226
DropWeaponByDesignerName(coach, "weapon_c4");
225227
coach.PlayerPawn.Value!.CommitSuicide(explode: false, force: true);
226228
}
227-
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};");
229+
Server.ExecuteCommand($"mp_suicide_penalty {suicidePenalty}; spec_freeze_time {specFreezeTime}; spec_freeze_time_lock {specFreezeTimeLock}; spec_freeze_deathanim_time {specFreezeDeathanim};");
228230
});
229231
}
230232
}

ConfigConvars.cs

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public partial class MatchZy
2727

2828
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);
2929

30+
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.", "");
31+
3032
[ConsoleCommand("matchzy_whitelist_enabled_default", "Whether Whitelist is enabled by default or not. Default value: false")]
3133
public void MatchZyWLConvar(CCSPlayerController? player, CommandInfo command)
3234
{

MatchZy.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public partial class MatchZy : BasePlugin
1313
{
1414

1515
public override string ModuleName => "MatchZy";
16-
public override string ModuleVersion => "0.8.4";
16+
public override string ModuleVersion => "0.8.5";
1717

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

Utility.cs

+12-3
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,14 @@ private void HandleMatchStart()
771771
{
772772
Server.PrintToChatAll($"{chatPrefix} {ChatColors.Green}MatchZy{ChatColors.Default} Plugin by {ChatColors.Green}WD-{ChatColors.Default}");
773773
}
774+
if (matchStartMessage.Value.Trim() != "" && matchStartMessage.Value.Trim() != "\"\"")
775+
{
776+
List<string> matchStartMessages = [.. matchStartMessage.Value.Split("$$$")];
777+
foreach (string message in matchStartMessages)
778+
{
779+
PrintToAllChat(GetColorTreatedString(FormatCvarValue(message.Trim())));
780+
}
781+
}
774782
}
775783

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

10341042
var roundEndEvent = new MatchZyRoundEndedEvent
10351043
{
@@ -1526,8 +1534,9 @@ public string FormatCvarValue(string value)
15261534

15271535
public void UpdateHostname()
15281536
{
1529-
if (hostnameFormat.Value.Trim() == "") return;
1530-
string formattedHostname = FormatCvarValue(hostnameFormat.Value);
1537+
string hostname = hostnameFormat.Value.Trim();
1538+
if (hostname == "" || hostname == "\"\"") return;
1539+
string formattedHostname = FormatCvarValue(hostname);
15311540
Log($"UPDATING HOSTNAME TO: {formattedHostname}");
15321541
Server.ExecuteCommand($"hostname {formattedHostname}");
15331542
}

cfg/MatchZy/config.cfg

+6
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,9 @@ matchzy_hostname_format "MatchZy | {TEAM1} vs {TEAM2}"
108108

109109
// Whether to show damage report after each round or not. Default: true.
110110
matchzy_enable_damage_report true
111+
112+
// Message to show when the match starts. Use $$$ to break message into multiple lines. Set to "" to disable.
113+
// Available variables: {TIME}, {MATCH_ID}, {MAP}, {MAPNUMBER}, {TEAM1}, {TEAM2}, {TEAM1_SCORE}, {TEAM2_SCORE}
114+
// Available Colors: {Default}, {Darkred}, {Green}, {LightYellow}, {LightBlue}, {Olive}, {Lime}, {Red}, {Purple}, {Grey}, {Yellow}, {Gold}, {Silver}, {Blue}, {DarkBlue}
115+
// Example: {Green} Welcome to the server! {Default} $$$ Agent models are not allowed and may lead to {Red}disqualification!{Default}
116+
matchzy_match_start_message ""

documentation/docs/configuration.md

+4
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ Example: `matchzy_demo_upload_url "https://your-website.com/upload-endpoint"` <b
126126
####`matchzy_hostname_format`
127127
: 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}`**
128128

129+
####`matchzy_match_start_message`
130+
: 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}
131+
<br>**`Default: ""`**
132+
129133
####`matchzy_loadbackup`
130134
: Loads a match backup from the given file. Relative to `csgo/MatchZyDataBackup/`.
131135

0 commit comments

Comments
 (0)