Skip to content

Commit

Permalink
Bumped version to 2.0.8, and implemented the forcebombsite and forceb…
Browse files Browse the repository at this point in the history
…ombsitestop commands
  • Loading branch information
B3none committed Jul 26, 2024
1 parent fbd3b4c commit b97fcad
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 12 deletions.
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,18 @@ When the plugin is first loaded it will create a `retakes_config.json` file in t
| ShouldRemoveSpectators | When a player is moved to spectators, remove them from all retake queues. Ensures that AFK plugins work as expected. | false | false | true |

## Commands
| Command | Arguments | Description | Permissions |
|-----------------|-----------------------------------|----------------------------------------------------------------------|-------------|
| !showspawns | <A / B> | Show the spawns for the specified bombsite. | @css/root |
| !addspawn | <CT / T> <Y / N (can be planter)> | Adds a retakes spawn point for the bombsite spawns currently shown. | @css/root |
| !removespawn | | Removes the nearest spawn point for the bombsite currently shown. | @css/root |
| !nearestspawn | | Teleports the player to the nearest spawn. | @css/root |
| !hidespawns | | Exits the spawn editing mode. | @css/root |
| !scramble | | Scrambles the teams next round. | @css/admin |
| !voices | | Toggles whether or not to hear the bombsite voice announcements. | |
| css_debugqueues | | **SERVER ONLY** Shows the current queue state in the server console. | |
| Command | Arguments | Description | Permissions |
|--------------------|-----------------------------------|----------------------------------------------------------------------|-------------|
| !forcebombsite | <A / B> | Force the retakes to occur from a single bombsite. | @css/root |
| !forcebombsitestop | | Clear the forced bombsite and return back to normal. | @css/root |
| !showspawns | <A / B> | Show the spawns for the specified bombsite. | @css/root |
| !addspawn | <CT / T> <Y / N (can be planter)> | Adds a retakes spawn point for the bombsite spawns currently shown. | @css/root |
| !removespawn | | Removes the nearest spawn point for the bombsite currently shown. | @css/root |
| !nearestspawn | | Teleports the player to the nearest spawn. | @css/root |
| !hidespawns | | Exits the spawn editing mode. | @css/root |
| !scramble | | Scrambles the teams next round. | @css/admin |
| !voices | | Toggles whether or not to hear the bombsite voice announcements. | |
| css_debugqueues | | **SERVER ONLY** Shows the current queue state in the server console. | |

## Stay up to date
Subscribe to **release** notifications and stay up to date with the latest features and patches:
Expand Down
43 changes: 41 additions & 2 deletions RetakesPlugin/RetakesPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace RetakesPlugin;
[MinimumApiVersion(220)]
public class RetakesPlugin : BasePlugin
{
private const string Version = "2.0.7";
private const string Version = "2.0.8";

#region Plugin info
public override string ModuleName => "Retakes Plugin";
Expand Down Expand Up @@ -56,6 +56,7 @@ public class RetakesPlugin : BasePlugin
private CCSPlayerController? _planter;
private CsTeam _lastRoundWinner = CsTeam.None;
private Bombsite? _showingSpawnsForBombsite;
private Bombsite? _forcedBombsite;

// TODO: We should really store this in SQLite, but for now we'll just store it in memory.
private readonly HashSet<CCSPlayerController> _hasMutedVoices = new();
Expand Down Expand Up @@ -97,6 +98,43 @@ public override void Load(bool hotReload)
}

#region Commands
[ConsoleCommand("css_forcebombsitestop", "Clear the forced bombsite and return back to normal.")]
[CommandHelper(minArgs: 1, usage: "[A/B]", whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
[RequiresPermissions("@css/root")]
public void OnCommandForceBombsiteStop(CCSPlayerController? player, CommandInfo commandInfo)
{
if (!Helpers.IsValidPlayer(player))
{
return;
}

_forcedBombsite = null;

commandInfo.ReplyToCommand($"{MessagePrefix}The bombsite will no longer be forced.");
}

[ConsoleCommand("css_forcebombsite", "Force the retakes to occur from a single bombsite.")]
[CommandHelper(whoCanExecute: CommandUsage.CLIENT_AND_SERVER)]
[RequiresPermissions("@css/root")]
public void OnCommandForceBombsite(CCSPlayerController? player, CommandInfo commandInfo)
{
if (!Helpers.IsValidPlayer(player))
{
return;
}

var bombsite = commandInfo.GetArg(1).ToUpper();
if (bombsite != "A" && bombsite != "B")
{
commandInfo.ReplyToCommand($"{MessagePrefix}You must specify a bombsite [A / B].");
return;
}

_forcedBombsite = bombsite == "A" ? Bombsite.A : Bombsite.B;

commandInfo.ReplyToCommand($"{MessagePrefix}The bombsite will now be forced to {_forcedBombsite}.");
}

[ConsoleCommand("css_showspawns", "Show the spawns for the specified bombsite.")]
[ConsoleCommand("css_spawns", "Show the spawns for the specified bombsite.")]
[ConsoleCommand("css_edit", "Show the spawns for the specified bombsite.")]
Expand Down Expand Up @@ -611,7 +649,7 @@ public HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)

// Reset round state.
_breakerManager?.Handle();
_currentBombsite = Helpers.Random.Next(0, 2) == 0 ? Bombsite.A : Bombsite.B;
_currentBombsite = _forcedBombsite ?? (Helpers.Random.Next(0, 2) == 0 ? Bombsite.A : Bombsite.B);
_gameManager.ResetPlayerScores();

Helpers.Debug("Clearing _showingSpawnsForBombsite");
Expand All @@ -638,6 +676,7 @@ public HookResult OnRoundPostStart(EventRoundPoststart @event, GameEventInfo inf
Helpers.Debug($"Game manager not loaded.");
return HookResult.Continue;
}

// If we are in warmup, skip.
if (Helpers.GetGameRules().WarmupPeriod)
{
Expand Down

0 comments on commit b97fcad

Please sign in to comment.