From 2f027d6b7f2c009fea67841640eab022acde28a4 Mon Sep 17 00:00:00 2001 From: MSWS Date: Tue, 20 Feb 2024 16:58:43 -0800 Subject: [PATCH] Add player check --- mod/Jailbreak.LastRequest/LastRequestCommand.cs | 7 ++++++- mod/Jailbreak.LastRequest/LastRequestPlayerSelector.cs | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mod/Jailbreak.LastRequest/LastRequestCommand.cs b/mod/Jailbreak.LastRequest/LastRequestCommand.cs index 40453365..433ecbaf 100644 --- a/mod/Jailbreak.LastRequest/LastRequestCommand.cs +++ b/mod/Jailbreak.LastRequest/LastRequestCommand.cs @@ -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()); @@ -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; } } } \ No newline at end of file diff --git a/mod/Jailbreak.LastRequest/LastRequestPlayerSelector.cs b/mod/Jailbreak.LastRequest/LastRequestPlayerSelector.cs index 8303fae9..b5f75ab6 100644 --- a/mod/Jailbreak.LastRequest/LastRequestPlayerSelector.cs +++ b/mod/Jailbreak.LastRequest/LastRequestPlayerSelector.cs @@ -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);