Skip to content

Commit

Permalink
Merge pull request #162 from shobhit-pathak/dev
Browse files Browse the repository at this point in the history
0.7.11 | Improved help, fixed overtime and other improvements
  • Loading branch information
shobhit-pathak committed May 19, 2024
2 parents daa140a + ae597e5 commit adb0c82
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 34 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# MatchZy Changelog

# 0.7.11

#### May 19, 2024

- Improved `.help` command with better readability and updated commands
- Fixed overtime getting automatically enabled even if turned off in `live.cfg`
- Added `matchzy_show_credits_on_match_start` config convar to toggle 'MatchZy Plugin by WD-' message on match start.
- Added gradient while printing `KNIFE!` and `LIVE!` message.
- Added `.pip` alias for `.traj` command to toggle `sv_grenade_trajectory_prac_pipreview` in practice mode.

# 0.7.10

#### May 19, 2024
Expand Down
2 changes: 2 additions & 0 deletions ConfigConvars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public partial class MatchZy

public FakeConVar<bool> everyoneIsAdmin = new("matchzy_everyone_is_admin", "If set to true, all the players will have admin privilege. Default: false", false);

public FakeConVar<bool> showCreditsOnMatchStart = new("matchzy_show_credits_on_match_start", "Whether to show 'MatchZy Plugin by WD-' message on match start. Default: true", true);

[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
10 changes: 2 additions & 8 deletions ConsoleCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -499,14 +499,8 @@ public void OnHelpCommand(CCSPlayerController? player, CommandInfo? command)
// player.PrintToChat($"{chatPrefix} Playout is now {ChatColors.Green}{playoutStatus}{ChatColors.Default}!");
PrintToPlayerChat(player, Localizer["matchzy.cc.playout", playoutStatus]);
}

if (isPlayOutEnabled) {
Server.ExecuteCommand("mp_overtime_enable 0");
Server.ExecuteCommand("mp_match_can_clinch false");
} else {
Server.ExecuteCommand("mp_match_can_clinch true");
Server.ExecuteCommand("mp_overtime_enable 1");
}

HandlePlayoutConfig();

} else {
SendPlayerNotAdminMessage(player);
Expand Down
14 changes: 14 additions & 0 deletions MatchManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -607,5 +607,19 @@ public void EndSeries(string? winnerName, int restartDelay, int t1score, int t2s
});
}

public void HandlePlayoutConfig()
{
if (isPlayOutEnabled) {
Server.ExecuteCommand("mp_overtime_enable 0");
Server.ExecuteCommand("mp_match_can_clinch false");
} else {
var absoluteCfgPath = Path.Join(Server.GameDirectory + "/csgo/cfg", GetGameMode() == 1 ? liveCfgPath : liveWingmanCfgPath);
string? matchCanClinch = GetConvarValueFromCFGFile(absoluteCfgPath, "mp_match_can_clinch");
string? overtimeEnabled = GetConvarValueFromCFGFile(absoluteCfgPath, "mp_overtime_enable");
Server.ExecuteCommand($"mp_match_can_clinch {matchCanClinch ?? "1"}");
Server.ExecuteCommand($"mp_overtime_enable {overtimeEnabled ?? "1"}");
}
}

}
}
3 changes: 2 additions & 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.7.10";
public override string ModuleVersion => "0.7.11";

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

Expand Down Expand Up @@ -156,6 +156,7 @@ public partial class MatchZy : BasePlugin
{ ".solid", OnSolidCommand },
{ ".impacts", OnImpactsCommand },
{ ".traj", OnTrajCommand },
{ ".pip", OnTrajCommand },
{ ".god", OnGodCommand },
{ ".ff", OnFastForwardCommand },
{ ".fastforward", OnFastForwardCommand },
Expand Down
12 changes: 7 additions & 5 deletions PracticeMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,12 @@ public void StartPracticeMode()
}
GetSpawns();
PrintToAllChat($"Practice mode loaded!");
PrintToAllChat($"Available commands:");
PrintToAllChat($".spawn, .ctspawn, .tspawn, .bot, .nobots, .dryrun, .noflash, .break, .exitprac");
PrintToAllChat($".loadnade <name>, .savenade <name>, .importnade <code>, .listnades <optional filter>");
PrintToAllChat($".listnades <optional filter>, .delnade <name>, .globalnades");
PrintToAllChat($".rethrow, .throwindex <index>, .lastindex, .last, .back <number>, .delay <number>");
Server.PrintToChatAll($" {ChatColors.Green}Spawns: {ChatColors.Default}.spawn, .ctspawn, .tspawn, .bestspawn, .worstspawn");
Server.PrintToChatAll($" {ChatColors.Green}Bots: {ChatColors.Default}.bot, .nobots, .crouchbot, .boost, .crouchboost");
Server.PrintToChatAll($" {ChatColors.Green}Nades: {ChatColors.Default}.loadnade, .savenade, .importnade, .listnades");
Server.PrintToChatAll($" {ChatColors.Green}Nade Throw: {ChatColors.Default}.rethrow, .throwindex <index>, .lastindex, .delay <number>");
Server.PrintToChatAll($" {ChatColors.Green}Utility & Toggles: {ChatColors.Default}.clear, .fastforward, .last, .back, .solid, .impacts, .traj");
Server.PrintToChatAll($" {ChatColors.Green}Sides & Others: {ChatColors.Default}.ct, .t, .spec, .fas, .god, .dryrun, .break, .exitprac");
}

public void GetSpawns()
Expand Down Expand Up @@ -1524,6 +1525,7 @@ public void OnImpactsCommand(CCSPlayerController? player, CommandInfo? command)
}

[ConsoleCommand("css_traj", "Toggles sv_grenade_trajectory_prac_pipreview in practice mode")]
[ConsoleCommand("css_pip", "Toggles sv_grenade_trajectory_prac_pipreview in practice mode")]
public void OnTrajCommand(CCSPlayerController? player, CommandInfo? command)
{
if (!isPractice || !IsPlayerValid(player)) return;
Expand Down
57 changes: 37 additions & 20 deletions Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ private void PrintToPlayerChat(CCSPlayerController player, string message)
Server.ExecuteCommand("mp_ct_default_secondary \"\";mp_free_armor 1;mp_freezetime 10;mp_give_player_c4 0;mp_maxmoney 0;mp_respawn_immunitytime 0;mp_respawn_on_death_ct 0;mp_respawn_on_death_t 0;mp_roundtime 1.92;mp_roundtime_defuse 1.92;mp_roundtime_hostage 1.92;mp_t_default_secondary \"\";mp_round_restart_delay 3;mp_team_intro_time 0;mp_restartgame 1;mp_warmup_end;");
}

PrintToAllChat($"{ChatColors.Green}KNIFE!");
PrintToAllChat($"{ChatColors.Green}KNIFE!");
PrintToAllChat($"{ChatColors.Olive}KNIFE!");
PrintToAllChat($"{ChatColors.Lime}KNIFE!");
PrintToAllChat($"{ChatColors.Green}KNIFE!");
}

Expand Down Expand Up @@ -240,19 +240,13 @@ private void PrintToPlayerChat(CCSPlayerController player, string message)
// This is to reload the map once it is over so that all flags are reset accordingly
Server.ExecuteCommand("mp_match_end_restart true");

PrintToAllChat($"{ChatColors.Green}LIVE!");
PrintToAllChat($"{ChatColors.Green}LIVE!");
PrintToAllChat($"{ChatColors.Olive}LIVE!");
PrintToAllChat($"{ChatColors.Lime}LIVE!");
PrintToAllChat($"{ChatColors.Green}LIVE!");

// Adding timer here to make sure that CFG execution is completed till then
AddTimer(1, () => {
if (isPlayOutEnabled) {
Server.ExecuteCommand("mp_overtime_enable 0");
Server.ExecuteCommand("mp_match_can_clinch false");
} else {
Server.ExecuteCommand("mp_match_can_clinch true");
Server.ExecuteCommand("mp_overtime_enable 1");
}
HandlePlayoutConfig();
ExecuteChangedConvars();
});

Expand Down Expand Up @@ -636,7 +630,10 @@ private void HandleKnifeWinner(EventCsWinPanelRound @event)
{
StartLive();
}
Server.PrintToChatAll($"{chatPrefix} {ChatColors.Green}MatchZy{ChatColors.Default} Plugin by {ChatColors.Green}WD-{ChatColors.Default}");
if (showCreditsOnMatchStart.Value)
{
Server.PrintToChatAll($"{chatPrefix} {ChatColors.Green}MatchZy{ChatColors.Default} Plugin by {ChatColors.Green}WD-{ChatColors.Default}");
}
}

public void HandleClanTags() {
Expand Down Expand Up @@ -1180,28 +1177,35 @@ private string GetColorTreatedString(string message)

private void SendAvailableCommandsMessage(CCSPlayerController? player)
{
if (!IsPlayerValid(player)) return;
if (isPractice)
{
ReplyToUserCommand(player, "Available commands: .spawn, .ctspawn, .tspawn, .bot, .nobots, .god, .clear, .fastforward, .dryrun");
ReplyToUserCommand(player, ".loadnade <name>, .savenade <name>, .importnade <code> .listnades <optional filter>");
ReplyToUserCommand(player, ".ct, .t, .spec, .fas");
ReplyToUserCommand(player, ".rethrow, .throwindex <index>, .lastindex, .last, .back <number>, .delay <number>");
ReplyToUserCommand(player, $"{ChatColors.Green}Available commands: {ChatColors.Default}");
player!.PrintToChat($" {ChatColors.Green}Spawns: {ChatColors.Default}.spawn, .ctspawn, .tspawn, .bestspawn, .worstspawn");
player.PrintToChat($" {ChatColors.Green}Bots: {ChatColors.Default}.bot, .nobots, .crouchbot, .boost, .crouchboost");
player.PrintToChat($" {ChatColors.Green}Nades: {ChatColors.Default}.loadnade, .savenade, .importnade, .listnades");
player.PrintToChat($" {ChatColors.Green}Nade Throw: {ChatColors.Default}.rethrow, .throwindex <index>, .lastindex, .delay <number>");
player.PrintToChat($" {ChatColors.Green}Utility & Toggles: {ChatColors.Default}.clear, .fastforward, .last, .back, .solid, .impacts, .traj");
player.PrintToChat($" {ChatColors.Green}Sides & Others: {ChatColors.Default}.ct, .t, .spec, .fas, .god, .dryrun, .break, .exitprac");
return;
}
if (readyAvailable)
{
ReplyToUserCommand(player, "Available commands: !ready, !unready");
ReplyToUserCommand(player, $"{ChatColors.Green}Available commands: {ChatColors.Default}");
player!.PrintToChat($" {ChatColors.Green}Ready/Unready: {ChatColors.Default}.ready, .unready");
return;
}
if (isSideSelectionPhase)
{
ReplyToUserCommand(player, "Available commands: !stay, !switch");
ReplyToUserCommand(player, $"{ChatColors.Green}Available commands: {ChatColors.Default}");
player!.PrintToChat($" {ChatColors.Green}Side Selection: {ChatColors.Default}.stay, .switch");
return;
}
if (matchStarted)
{
string stopCommandMessage = isStopCommandAvailable ? ", !stop" : "";
ReplyToUserCommand(player, $"Available commands: !pause, !unpause, !tac, !tech{stopCommandMessage}");
string stopCommandMessage = isStopCommandAvailable ? ", .stop" : "";
ReplyToUserCommand(player, $"{ChatColors.Green}Available commands: {ChatColors.Default}");
player!.PrintToChat($" {ChatColors.Green}Pause/Restore: {ChatColors.Default}.pause, .unpause, .tac, .tech{stopCommandMessage}");
return;
}
}
Expand Down Expand Up @@ -1593,5 +1597,18 @@ public static Color GetPlayerTeammateColor(CCSPlayerController playerController)
_ => Color.Red,
};
}

public static string? GetConvarValueFromCFGFile(string filePath, string convarName)
{
var fileContent = File.ReadAllText(filePath);

string pattern = @$"^{convarName}\s+(.+)$";

Regex regex = new(pattern, RegexOptions.Multiline);

Match match = regex.Match(fileContent);
string? value = match.Success ? match.Groups[1].Value : null;
return value;
}
}
}
3 changes: 3 additions & 0 deletions cfg/MatchZy/config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,6 @@ matchzy_smoke_color_enabled false

// If set to true, all the players will have admin privilege. Default: false
matchzy_everyone_is_admin false

// Whether to show 'MatchZy Plugin by WD-' message on match start. Default: true
matchzy_show_credits_on_match_start true
3 changes: 3 additions & 0 deletions documentation/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ Example: `matchzy_demo_upload_url "https://your-website.com/upload-endpoint"` <b
####`matchzy_everyone_is_admin`
: If set to true, everyone will be granted admin permissions for MatchZy.<br>**`Default: false`**

####`matchzy_show_credits_on_match_start`
: Whether to show 'MatchZy Plugin by WD-' message on match start.<br>**`Default: true`**

### Configuring Warmup/Knife/Live/Prac CFGs
Again, inside `csgo/cfg/MatchZy`, files named `warmup.cfg`, `knife.cfg`, `live.cfg` and `prac.cfg` should be present. These configs are executed when Warmup, Knife, Live and Practice Mode is started respectively.

Expand Down

0 comments on commit adb0c82

Please sign in to comment.