From 668b66e1d5bb4ec6a96db0835011dd9380bcd07b Mon Sep 17 00:00:00 2001 From: Yoni Lerner Date: Sun, 31 Mar 2024 17:45:03 -0700 Subject: [PATCH] add half buy to !guns --- RetakesAllocator/Menus/GunsMenu.cs | 62 ++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/RetakesAllocator/Menus/GunsMenu.cs b/RetakesAllocator/Menus/GunsMenu.cs index d640a24..4dbce96 100644 --- a/RetakesAllocator/Menus/GunsMenu.cs +++ b/RetakesAllocator/Menus/GunsMenu.cs @@ -257,6 +257,68 @@ private void OnCtPistolSelect(CCSPlayerController player, ChatMenuOption option) player.PrintToChat($"{MessagePrefix} You selected {weaponName} as CT Pistol Round Weapon!"); HandlePreferenceSelection(player, CsTeam.CounterTerrorist, weaponName); + OpenTHalfBuyMenu(player); + } + + private void OpenTHalfBuyMenu(CCSPlayerController player) + { + var menu = new ChatMenu($"{MessagePrefix} Select a T Half Buy Weapon"); + + foreach (var weapon in WeaponHelpers.GetPossibleWeaponsForAllocationType(WeaponAllocationType.HalfBuyPrimary, + CsTeam.Terrorist)) + { + menu.AddMenuOption(weapon.GetName(), OnTHalfBuySelect); + } + + menu.AddMenuOption("Exit", OnSelectExit); + + ChatMenus.OpenMenu(player, menu); + CreateMenuTimeoutTimer(player); + } + + private void OnTHalfBuySelect(CCSPlayerController player, ChatMenuOption option) + { + if (!PlayersInMenu.Contains(player)) + { + return; + } + + var weaponName = option.Text; + + player.PrintToChat($"{MessagePrefix} You selected {weaponName} as T Half Buy Weapon!"); + HandlePreferenceSelection(player, CsTeam.Terrorist, weaponName); + + OpenCTHalfBuyMenu(player); + } + + private void OpenCTHalfBuyMenu(CCSPlayerController player) + { + var menu = new ChatMenu($"{MessagePrefix} Select a CT Half Buy Weapon"); + + foreach (var weapon in WeaponHelpers.GetPossibleWeaponsForAllocationType(WeaponAllocationType.HalfBuyPrimary, + CsTeam.CounterTerrorist)) + { + menu.AddMenuOption(weapon.GetName(), OnCTHalfBuySelect); + } + + menu.AddMenuOption("Exit", OnSelectExit); + + ChatMenus.OpenMenu(player, menu); + CreateMenuTimeoutTimer(player); + } + + private void OnCTHalfBuySelect(CCSPlayerController player, ChatMenuOption option) + { + if (!PlayersInMenu.Contains(player)) + { + return; + } + + var weaponName = option.Text; + + player.PrintToChat($"{MessagePrefix} You selected {weaponName} as CT Half Buy Weapon!"); + HandlePreferenceSelection(player, CsTeam.CounterTerrorist, weaponName); + OpenGiveAwpMenu(player); }