Skip to content

Commit

Permalink
v0.7.0 | feat: Rethrow in prac and much more
Browse files Browse the repository at this point in the history
  • Loading branch information
shobhit-pathak committed Feb 10, 2024
1 parent db9e03f commit e0ffc62
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 8 deletions.
30 changes: 28 additions & 2 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.6.1-alpha";
public override string ModuleVersion => "0.7.0";

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

Expand Down Expand Up @@ -170,7 +170,9 @@ public override void Load(bool hotReload) {
{ ".rethrowdecoy", OnRethrowDecoyCommand },
{ ".throwdecoy", OnRethrowDecoyCommand },
{ ".throwmolotov", OnRethrowMolotovCommand },
{ ".rethrowmolotov", OnRethrowMolotovCommand }
{ ".rethrowmolotov", OnRethrowMolotovCommand },
{ ".timer", OnTimerCommand },
{ ".lastindex", OnLastIndexCommand }
};

RegisterEventHandler<EventPlayerConnectFull>(EventPlayerConnectFullHandler);
Expand Down Expand Up @@ -491,6 +493,30 @@ public override void Load(bool hotReload) {

HandeMapPickCommand(player, mapArg);
}
if (message.StartsWith(".back")) {
string command = ".back";
string commandArg = message.Substring(command.Length).Trim();

HandleBackCommand(player, commandArg);
}
if (message.StartsWith(".delay")) {
string command = ".delay";
string commandArg = message.Substring(command.Length).Trim();

HandleDelayCommand(player, commandArg);
}
if (message.StartsWith(".throwindex")) {
string command = ".throwindex";
string commandArg = message.Substring(command.Length).Trim();

HandleThrowIndexCommand(player, commandArg);
}
if (message.StartsWith(".throwidx")) {
string command = ".throwindex";
string commandArg = message.Substring(command.Length).Trim();

HandleThrowIndexCommand(player, commandArg);
}

return HookResult.Continue;
});
Expand Down
32 changes: 28 additions & 4 deletions PracticeMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public void StartPracticeMode()
Server.PrintToChatAll($"{chatPrefix} \x10.spawn, .ctspawn, .tspawn, .bot, .nobots, .dryrun, .noflash, .break, .exitprac");
Server.PrintToChatAll($"{chatPrefix} \x10.loadnade <name>, .savenade <name>, .importnade <code>, .listnades <optional filter>");
Server.PrintToChatAll($"{chatPrefix} \x10.listnades <optional filter>, .delnade <name>, .globalnades");
Server.PrintToChatAll($"{chatPrefix} \x10.rethrow, .throwindex <index>, .lastindex, .last, .back <number>, .delay <number>");
}

public void GetSpawns()
Expand Down Expand Up @@ -1171,6 +1172,13 @@ public void HandleThrowIndexCommand(CCSPlayerController player, string argString
if (!isPractice || !IsPlayerValid(player)) return;
int userId = player!.UserId!.Value;

if (string.IsNullOrEmpty(argString))
{
int thrownCount = lastGrenadesData.ContainsKey(userId) ? lastGrenadesData[userId].Count : 0;
ReplyToUserCommand(player, $"Usage: !throwindex <number> (You've thrown {thrownCount} grenades till now)");
return;
}

string[] argsList = argString.Split();

foreach (string arg in argsList)
Expand Down Expand Up @@ -1332,7 +1340,7 @@ public void OnThrowIndexCommand(CCSPlayerController? player, CommandInfo command
}

[ConsoleCommand("css_lastindex", "Returns index of the last thrown grenade")]
public void OnLastIndexCommand(CCSPlayerController? player, CommandInfo command)
public void OnLastIndexCommand(CCSPlayerController? player, CommandInfo? command)
{
if (!isPractice || !IsPlayerValid(player)) return;
if (IsValidPositionForLastGrenade(player!, 1))
Expand All @@ -1356,7 +1364,7 @@ public void OnDelayCommand(CCSPlayerController? player, CommandInfo command)
}

[ConsoleCommand("css_timer", "Starts a timer, use .timer again to stop it.")]
public void OnTimerCommand(CCSPlayerController? player, CommandInfo command)
public void OnTimerCommand(CCSPlayerController? player, CommandInfo? command)
{
if (!isPractice || !IsPlayerValid(player)) return;
int userId = player!.UserId!.Value;
Expand All @@ -1370,7 +1378,7 @@ public void OnTimerCommand(CCSPlayerController? player, CommandInfo command)
}
else
{
playerTimers[userId] = new PlayerPracticeTimer(PracticeTimerType.OnMovement)
playerTimers[userId] = new PlayerPracticeTimer(PracticeTimerType.Immediate)
{
StartTime = DateTime.Now,
Timer = AddTimer(0.1f, () => DisplayPracticeTimerCenter(userId), TimerFlags.REPEAT)
Expand All @@ -1379,7 +1387,23 @@ public void OnTimerCommand(CCSPlayerController? player, CommandInfo command)
}
}

// Todo: Implement timer2 when we have OnPlayerRunCmd in CS#. Using OnTick would be its alternative, it would be very expensive and not worth it.
[ConsoleCommand("css_savenade", "Saves current nade position")]
public void OnSaveNadeCommand(CCSPlayerController? player, CommandInfo command)
{
if (!isPractice || !IsPlayerValid(player)) return;

HandleSaveNadeCommand(player, command.ArgString);
}

[ConsoleCommand("css_loadnade", "Saves current nade position")]
public void OnLoadNadeCommand(CCSPlayerController? player, CommandInfo command)
{
if (!isPractice || !IsPlayerValid(player)) return;

HandleLoadNadeCommand(player, command.ArgString);
}

// Todo: Implement timer2 when we have OnPlayerRunCmd in CS#. Using OnTick would be its alternative, but it would be very expensive and not worth it.
// [ConsoleCommand("css_timer2", "Starts a timer, use .timer2 again to stop it.")]
// public void OnTimer2Command(CCSPlayerController? player, CommandInfo command)
// {
Expand Down
3 changes: 2 additions & 1 deletion Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1137,9 +1137,10 @@ private void SendAvailableCommandsMessage(CCSPlayerController? player)
{
if (isPractice)
{
ReplyToUserCommand(player, "Available commands: .spawn, .ctspawn, .tspawn, .bot, .nobots, .god, .clear, .fastforward");
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>");
return;
}
if (readyAvailable)
Expand Down
2 changes: 1 addition & 1 deletion cfg/MatchZy/config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ matchzy_save_nades_as_global_enabled false
// Whether force ready using !forceready is enabled or not (Currently works in Match Setup only). Default value: True
matchzy_allow_force_ready true

// Maximum number of grenade history that may be saved per-map, per-client. Set to 0 to disable. Default value: 512
// Maximum number of grenade history that may be saved per-map, per-client. Set to 0 to disable the limit and allow unlimited grenades to be stored. Default value: 512
matchzy_max_saved_last_grenades 512
13 changes: 13 additions & 0 deletions documentation/docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Most of the commands can also be used using ! prefix instead of . (like !ready)

- `.ready` Marks the player ready
- `.unready` Marks the player unready
- `.forceready` Force-readies the player's team (Only works when using Match setup using JSON/Get5)
- `.pause` Pauses the match in freezetime (Tactical or normal pause, depends on `matchzy_use_pause_command_for_tactical_pause`).
- `.tech` Pauses the match in freezetime.
- `.unpause` Request for unpausing the match. Both teams need to type .unpause to unpause the match
Expand Down Expand Up @@ -35,6 +36,18 @@ Most of the commands can also be used using ! prefix instead of . (like !ready)
- `.importnade <code>` Upon saving a lineup a code will be printed to chat, alternatively those can be retrieved from the savednades.cfg
- `.listnades <optional filter>` Lists either all saved lineups ever or if given a filter only those that match the filter
- `.break` Breaks all the breakable entities (glass windows, wooden doors, vents, etc)
- `.rethrow` Rethrows your last thrown grenade
- `.timer` Starts a timer immediately and stops it when you type .timer again, telling you the duration of time
- `.last` Teleports you back to where you threw your last grenade from
- `.back <number>` Teleports you back to the provided position in your grenade history
- `.delay <delay_in_seconds>` Sets a delay on your last grenade. This is only used when using .rethrow or .throwindex
- `.throwindex <index> <optional index> <optional index>` Throws grenade of provided position(s) from your grenade thrown history. Example: `.throwindex 1 2` will throw your 1st and 2nd grenade. `.throwindex 4 5 8 9` will throw your 4th, 5th, 8th and 9th grenade (If you've added delay in grenades, they'll be thrown with their specific delay).
- `.lastindex` Prints index number of your last thrown grenade.
- `.rethrowsmoke` Throws your last thrown smoke grenade.
- `.rethrownade` Throws your last thrown HE grenade.
- `.rethrowflash` Throws your last thrown flash.
- `.rethrowmolotov` Throws your last thrown molotov.
- `.rethrowdecoy` Throws your last thrown decoy.

# Admin Commands

Expand Down
6 changes: 6 additions & 0 deletions documentation/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ Example: `matchzy_demo_upload_url "https://your-website.com/upload-endpoint"` <b
####`matchzy_save_nades_as_global_enabled`
: Whether nades should be saved globally instead of being privated to players by default or not.<br>**`Default: false`**

####`matchzy_allow_force_ready`
: Whether force ready using !forceready is enabled or not (Currently works in Match Setup only).<br>**`Default: true`**

####`matchzy_max_saved_last_grenades`
: Maximum number of grenade history that may be saved per-map, per-client. Set to 0 to disable the limit and allow unlimited grenades to be stored.<br>**`Default: 512`**

### 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 e0ffc62

Please sign in to comment.