Skip to content

Commit

Permalink
Add player check
Browse files Browse the repository at this point in the history
  • Loading branch information
MSWS committed Feb 21, 2024
1 parent 481409b commit 2f027d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mod/Jailbreak.LastRequest/LastRequestCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ public void Command_LastRequest(CCSPlayerController? executor, CommandInfo info)
return;
}

if (!playerSelector.WouldHavePlayers())
{
info.ReplyToCommand("There are no players available to LR.");
return;
}

if (info.ArgCount == 1)
{
MenuManager.OpenCenterHtmlMenu(plugin, executor, menuSelector.GetMenu());
Expand Down Expand Up @@ -112,7 +118,6 @@ public void Command_LastRequest(CCSPlayerController? executor, CommandInfo info)
if (!_lrManager.InitiateLastRequest(executor, player, (LRType)type))
{
info.ReplyToCommand("An error occurred while initiating the last request. Please try again later.");
return;
}
}
}
2 changes: 2 additions & 0 deletions mod/Jailbreak.LastRequest/LastRequestPlayerSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public CenterHtmlMenu CreateMenu(CCSPlayerController player, LRType lrType)
return menu;
}

public bool WouldHavePlayers() => Utilities.GetPlayers().Any(p => p.IsReal() && p is { PawnIsAlive: true, Team: CsTeam.CounterTerrorist });

private void OnSelect(CCSPlayerController player, ChatMenuOption option, LRType lr, CCSPlayerController target)
{
player.ExecuteClientCommandFromServer("css_lr " + ((int) lr) + " #" + target.UserId);
Expand Down

0 comments on commit 2f027d6

Please sign in to comment.