From 11dc227718f4600b6d67d3d766d74af2437d8029 Mon Sep 17 00:00:00 2001 From: Yoni Lerner Date: Sun, 28 Apr 2024 22:55:57 -0400 Subject: [PATCH] Oqyh main (#149) Co-authored-by: Gold KingZ <48490385+oqyh@users.noreply.github.com> --- Resources/ASITE.png | Bin 0 -> 3508 bytes Resources/BSITE.png | Bin 0 -> 3678 bytes RetakesAllocator/CustomGameData.cs | 42 ++-- RetakesAllocator/Helpers.cs | 6 + RetakesAllocator/Menus/AdvancedGunMenu.cs | 129 ++++++++-- RetakesAllocator/Menus/GunsMenu.cs | 22 +- RetakesAllocator/Menus/MenuManager.cs | 5 +- RetakesAllocator/Menus/VoteMenu.cs | 4 +- RetakesAllocator/RetakesAllocator.cs | 233 ++++++++++++++++-- RetakesAllocator/lang/en.json | 23 +- RetakesAllocatorCore/Config/Configs.cs | 15 +- RetakesAllocatorCore/OnWeaponCommandHelper.cs | 18 +- RetakesAllocatorCore/PluginInfo.cs | 2 +- 13 files changed, 413 insertions(+), 86 deletions(-) create mode 100644 Resources/ASITE.png create mode 100644 Resources/BSITE.png diff --git a/Resources/ASITE.png b/Resources/ASITE.png new file mode 100644 index 0000000000000000000000000000000000000000..22b777c5c57d848458170f5fedeafb604e368cec GIT binary patch literal 3508 zcmV;l4NLNgP)7{BL9MiGX=-G7UnXQ?X{MxsmsGSMG(|cAU8!goC9a~$8YvJo6XEOGiT2} zduE^aS!*v~&o|%9-kkZJ_j_+&O;b}7hG7^QU<0roSOKgB-UHqTHUcd`7oZ2Q8kp~mDW(qSR_PCFl$RRIl!0o^tz$=yhkVgArg3|HW12`Wz4p|{CRsnAV>wvA^do@4~3DQW% zxtoB6zyjbQ;3eR7?_8rwF+u4#^Z?F5VzPr{+$!Kv;7;I4U=3Q<6jKk315O4G0QN;< z6T~LqdEiE1Ch%dUzYrsNOi(%oM*)`sqa0(N1ZDvDAzw)x>b$u>0UYLCud8GH^T5Tx zy_NoAjASuEscv=#egS;lG3LL(6yQOUTaN67ESJ-P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or=g(gsyx@qkoQtfh7hlo!^0nsaR zp37CqR-hoMtH`b?HOPR)VNm8F@!V|uj?(CawqmX$G~PwWp++4_W)u-KD9L4)mr#oM4*cRHppNsOmTjo#%ALTR0`40PT!+qBc5xl>HtyC2Mv*atl1}nz zMs7jEwydYJH#$9V4)B)eyjz-lpFyeUO4Lg7cHnU&pYMRST=hte`znQf*eg)X=Ry?s ziCWjgs4s0tl%+B)N&+#1Qaa2+?E|KvZN?=i{<6A&IVzFhZ2=Ogm7z0#vPSBG;B~^7 zf&#)({Z;xR&uN0^x_Y2ClJ?OB*Mfj!0qZ%M4&T;aiAt zxckTUM<3j`P)uVfjcp_QBjePZQ~ORto=NWl?ztDmPj;YQxCbKRIIDm;j8?)7N^-dk z_!2tT<^ufW=A)5rC9Ge_GNiUGMz!vAl$9!^!SwSKe)^zMM9iQhmu)om4jBn7_PpdsR~NQyq1`^nAe@5YHk(lW&xfcm z@okhgu0@4@<59MzJ*qhx6};B{D9thv64`pE*P_Xqj;H#(@u*zd?4Zuv`7x-_djD%wbrS$2B z4)Qu9V%%HEBU*@#Dt(3gBDF(M>UVzd{b=OfOvS(H(kvvh^Ep%5ND*dG+72h9_6B1- z$FB|^*%-=dBrfZMda(>gmC1uW=L6|ruD~7NF;a{fl(t1V3XqORF`6R@KjkkjYS8xR z9^gR=Q~nw$!wgE>W;oKNOhksJxhL}NM1r*C!DBIM+*F7L#Yiz`Pz;dgGLpt~j)$Up zo36N}@>|eWXda4(tUyP3Y%cZ>WE2N8D28Fgh6&pY!-x$tD28Fgh8YyYFk-_DieVVB wQI^SMd^@5WhG96VsIRYYuJ*t%3? GiveNamedItem2; + private readonly MemoryFunctionVoid GiveNamedItem2; public readonly MemoryFunctionWithReturn @@ -53,21 +52,16 @@ public readonly public CustomGameData() { - var giveNamedItemData = GetCustomGameDataKey("GiveNamedItem2"); - if (giveNamedItemData is not null) - { - GiveNamedItem2 = new(giveNamedItemData); - } - + GiveNamedItem2 = new(GetCustomGameDataKey("GiveNamedItem2")); CCSPlayer_CanAcquireFunc = new(GetCustomGameDataKey("CCSPlayer_CanAcquire")); GetCSWeaponDataFromKeyFunc = new(GetCustomGameDataKey("GetCSWeaponDataFromKey")); } - private string? GetCustomGameDataKey(string key) + private string GetCustomGameDataKey(string key) { if (!_customGameData.TryGetValue(key, out var customGameData)) { - return null; + throw new Exception($"Invalid key {key}"); } OSPlatform platform; @@ -84,7 +78,9 @@ public CustomGameData() throw new Exception("Unsupported platform"); } - return customGameData.TryGetValue(platform, out var customData) ? customData : null; + return customGameData.TryGetValue(platform, out var customData) + ? customData + : throw new Exception($"Missing custom data for {key} on {platform}"); } public void PlayerGiveNamedItem(CCSPlayerController player, string item) @@ -94,16 +90,8 @@ public void PlayerGiveNamedItem(CCSPlayerController player, string item) if (!player.PlayerPawn.Value.IsValid) return; if (player.PlayerPawn.Value.ItemServices == null) return; - if (GiveNamedItem2 is not null) - { - Log.Debug("Using custom function for GiveNamedItem2"); - GiveNamedItem2.Invoke(player.PlayerPawn.Value.ItemServices.Handle, item, 0, 0, 0, 0, 0, 0); - } - else - { - Log.Debug("Using default function for GiveNamedItem2"); - player.GiveNamedItem(item); - } + // Log.Debug("Using custom function for GiveNamedItem2"); + GiveNamedItem2.Invoke(player.PlayerPawn.Value.ItemServices.Handle, item, 0, 0, 0, 0, 0, 0); } } @@ -128,4 +116,4 @@ public enum AcquireMethod { PickUp = 0, Buy, -}; \ No newline at end of file +}; diff --git a/RetakesAllocator/Helpers.cs b/RetakesAllocator/Helpers.cs index 621ee30..0f077f9 100644 --- a/RetakesAllocator/Helpers.cs +++ b/RetakesAllocator/Helpers.cs @@ -1,3 +1,4 @@ +using System.Runtime.InteropServices; using CounterStrikeSharp.API; using CounterStrikeSharp.API.Core; using CounterStrikeSharp.API.Modules.Admin; @@ -194,5 +195,10 @@ public static int GetNumPlayersOnTeam() .Count; } + public static bool IsWindows() + { + return RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + } + public static bool IsVip(CCSPlayerController player) => AdminManager.PlayerHasPermissions(player, "@css/vip"); } diff --git a/RetakesAllocator/Menus/AdvancedGunMenu.cs b/RetakesAllocator/Menus/AdvancedGunMenu.cs index f43dc21..304f77e 100644 --- a/RetakesAllocator/Menus/AdvancedGunMenu.cs +++ b/RetakesAllocator/Menus/AdvancedGunMenu.cs @@ -16,10 +16,13 @@ public class AdvancedGunMenu public Dictionary mainmenu = new Dictionary(); public Dictionary currentIndexDict = new Dictionary(); public Dictionary buttonPressed = new Dictionary(); - + private static void Print(CCSPlayerController player, string message) + { + Helpers.WriteNewlineDelimited(message, player.PrintToChat); + } public HookResult OnEventPlayerChat(EventPlayerChat @event, GameEventInfo info) { - if(string.IsNullOrEmpty(Configs.GetConfigData().InGameGunMenuCenterCommands) || @event == null)return HookResult.Continue; + if(@event == null)return HookResult.Continue; var eventplayer = @event.Userid; var eventmessage = @event.Text; var player = Utilities.GetPlayerFromUserid(eventplayer); @@ -77,22 +80,26 @@ public void OnTick() List TFullBuyList = new List(); List TSecondaryList = new List(); + List THalfBuyList = new List(); List TPistolRoundList = new List(); List CTFullBuyList = new List(); List CTSecondaryList = new List(); + List CTHalfBuyList = new List(); List CTPistolRoundList = new List(); string[] Tloadout = { string.IsNullOrEmpty(Translator.Instance["menu.tprimary"]) ? "█ T Primary █" : Translator.Instance["menu.tprimary"], - string.IsNullOrEmpty(Translator.Instance["menu.tsecondary"]) ? "█ T Secondary █" : Translator.Instance["menu.tsecondary"], - string.IsNullOrEmpty(Translator.Instance["menu.tPistol"]) ? "█ T Pistol Round █" : Translator.Instance["menu.tPistol"] + string.IsNullOrEmpty(Translator.Instance["menu.tsecondary"]) ? "█ T Secondary █" : Translator.Instance["menu.tsecondary"], + string.IsNullOrEmpty(Translator.Instance["menu.tPistol"]) ? "█ T Pistol Round █" : Translator.Instance["menu.tPistol"], + string.IsNullOrEmpty(Translator.Instance["menu.tHalfbuy"]) ? "█ T Half Buy █" : Translator.Instance["menu.tHalfbuy"] }; string[] CTloadout = { string.IsNullOrEmpty(Translator.Instance["menu.ctprimary"]) ? "█ CT Primary █" : Translator.Instance["menu.ctprimary"], string.IsNullOrEmpty(Translator.Instance["menu.ctsecondary"]) ? "█ CT Secondary █" : Translator.Instance["menu.ctsecondary"], - string.IsNullOrEmpty(Translator.Instance["menu.ctPistol"]) ? "█ CT Pistol Round █" : Translator.Instance["menu.ctPistol"] + string.IsNullOrEmpty(Translator.Instance["menu.ctPistol"]) ? "█ CT Pistol Round █" : Translator.Instance["menu.ctPistol"], + string.IsNullOrEmpty(Translator.Instance["menu.ctHalfbuy"]) ? "█ CT Half Buy █" : Translator.Instance["menu.ctHalfbuy"] }; string[] AWP = { @@ -109,6 +116,10 @@ public void OnTick() { TSecondaryList.Add(weapon.GetName()); } + foreach (var weapon in WeaponHelpers.GetPossibleWeaponsForAllocationType(WeaponAllocationType.HalfBuyPrimary, CsTeam.Terrorist)) + { + THalfBuyList.Add(weapon.GetName()); + } foreach (var weapon in WeaponHelpers.GetPossibleWeaponsForAllocationType(WeaponAllocationType.PistolRound, CsTeam.Terrorist)) { TPistolRoundList.Add(weapon.GetName()); @@ -122,6 +133,10 @@ public void OnTick() { CTSecondaryList.Add(weapon.GetName()); } + foreach (var weapon in WeaponHelpers.GetPossibleWeaponsForAllocationType(WeaponAllocationType.HalfBuyPrimary, CsTeam.CounterTerrorist)) + { + CTHalfBuyList.Add(weapon.GetName()); + } foreach (var weapon in WeaponHelpers.GetPossibleWeaponsForAllocationType(WeaponAllocationType.PistolRound, CsTeam.CounterTerrorist)) { CTPistolRoundList.Add(weapon.GetName()); @@ -129,10 +144,12 @@ public void OnTick() string[] TFullBuy = TFullBuyList.ToArray(); string[] TSecondary = TSecondaryList.ToArray(); + string[] THalfBuy = THalfBuyList.ToArray(); string[] TPistolRound = TPistolRoundList.ToArray(); string[] CTFullBuy = CTFullBuyList.ToArray(); string[] CTSecondary = CTSecondaryList.ToArray(); + string[] CTHalfBuy = CTHalfBuyList.ToArray(); string[] CTPistolRound = CTPistolRoundList.ToArray(); if (player.Buttons == 0) @@ -162,6 +179,10 @@ public void OnTick() { currentIndexDict[playerid] = (currentIndexDict[playerid] == TPistolRound.Length - 1) ? 0 : currentIndexDict[playerid] + 1; } + if (mainmenu[playerid] == 10)//T Half Buy + { + currentIndexDict[playerid] = (currentIndexDict[playerid] == THalfBuy.Length - 1) ? 0 : currentIndexDict[playerid] + 1; + } if (mainmenu[playerid] == 5)//CT loadout { @@ -184,9 +205,13 @@ public void OnTick() { currentIndexDict[playerid] = (currentIndexDict[playerid] == AWP.Length - 1) ? 0 : currentIndexDict[playerid] + 1; } + if (mainmenu[playerid] == 11)//CT Half Buy + { + currentIndexDict[playerid] = (currentIndexDict[playerid] == CTHalfBuy.Length - 1) ? 0 : currentIndexDict[playerid] + 1; + } buttonPressed[playerid] = true; - player.ExecuteClientCommand("play sounds/ui/csgo_ui_page_scroll.vsnd_c"); + player.ExecuteClientCommand("play sounds/ui/csgo_ui_contract_type4.vsnd_c"); } else if (player.Buttons == PlayerButtons.Forward && !buttonPressed[playerid]) { @@ -211,6 +236,10 @@ public void OnTick() { currentIndexDict[playerid] = (currentIndexDict[playerid] == 0) ? TPistolRound.Length - 1 : currentIndexDict[playerid] - 1; } + if (mainmenu[playerid] == 10)//T Half Buy + { + currentIndexDict[playerid] = (currentIndexDict[playerid] == 0) ? THalfBuy.Length - 1 : currentIndexDict[playerid] - 1; + } if (mainmenu[playerid] == 5)//CT loadout { @@ -233,9 +262,13 @@ public void OnTick() { currentIndexDict[playerid] = (currentIndexDict[playerid] == 0) ? AWP.Length - 1 : currentIndexDict[playerid] - 1; } + if (mainmenu[playerid] == 11)//CT Half Buy + { + currentIndexDict[playerid] = (currentIndexDict[playerid] == 0) ? CTHalfBuy.Length - 1 : currentIndexDict[playerid] - 1; + } buttonPressed[playerid] = true; - player.ExecuteClientCommand("play sounds/ui/csgo_ui_page_scroll.vsnd_c"); + player.ExecuteClientCommand("play sounds/ui/csgo_ui_contract_type4.vsnd_c"); }else if ((player.Buttons == PlayerButtons.Moveleft || player.Buttons == PlayerButtons.Moveright) && !buttonPressed[playerid]) { int currentLineIndex = currentIndexDict[playerid]; @@ -244,38 +277,50 @@ public void OnTick() { string currentLineTFullBuy = TFullBuy[currentLineIndex]; GunsMenu.HandlePreferenceSelection(player, CsTeam.Terrorist, currentLineTFullBuy); - player.PrintToChat($"{MessagePrefix} You selected {currentLineTFullBuy} as T Primary!"); + Print(player, Translator.Instance["guns_menu.weapon_selected",currentLineTFullBuy, Utils.TeamString(CsTeam.Terrorist),Translator.Instance["weapon_type.primary"]]); } if (mainmenu[playerid] == 3) { string currentLineTSec = TSecondary[currentLineIndex]; GunsMenu.HandlePreferenceSelection(player, CsTeam.Terrorist, currentLineTSec, RoundType.FullBuy); - player.PrintToChat($"{MessagePrefix} You selected {currentLineTSec} as T Secondary!"); + Print(player, Translator.Instance["guns_menu.weapon_selected",currentLineTSec, Utils.TeamString(CsTeam.Terrorist),Translator.Instance["weapon_type.secondary"]]); } if (mainmenu[playerid] == 4) { string currentLineTPR = TPistolRound[currentLineIndex]; GunsMenu.HandlePreferenceSelection(player, CsTeam.Terrorist, currentLineTPR); - player.PrintToChat($"{MessagePrefix} You selected {currentLineTPR} as T Pistol Round Weapon!"); + Print(player, Translator.Instance["guns_menu.weapon_selected",currentLineTPR, Utils.TeamString(CsTeam.Terrorist),Translator.Instance["roundtype.Pistol"]]); + } + if (mainmenu[playerid] == 10) + { + string currentLineTHalf = THalfBuy[currentLineIndex]; + GunsMenu.HandlePreferenceSelection(player, CsTeam.Terrorist, currentLineTHalf); + Print(player, Translator.Instance["guns_menu.weapon_selected",currentLineTHalf, Utils.TeamString(CsTeam.Terrorist),Translator.Instance["roundtype.HalfBuy"]]); + } + if (mainmenu[playerid] == 11) + { + string currentLineCTHalf = CTHalfBuy[currentLineIndex]; + GunsMenu.HandlePreferenceSelection(player, CsTeam.CounterTerrorist, currentLineCTHalf); + Print(player, Translator.Instance["guns_menu.weapon_selected",currentLineCTHalf, Utils.TeamString(CsTeam.CounterTerrorist),Translator.Instance["roundtype.HalfBuy"]]); } if (mainmenu[playerid] == 6) { string currentLineCTFullBuy = CTFullBuy[currentLineIndex]; GunsMenu.HandlePreferenceSelection(player, CsTeam.CounterTerrorist, currentLineCTFullBuy); - player.PrintToChat($"{MessagePrefix} You selected {currentLineCTFullBuy} as CT Primary!"); + Print(player, Translator.Instance["guns_menu.weapon_selected",currentLineCTFullBuy, Utils.TeamString(CsTeam.CounterTerrorist),Translator.Instance["weapon_type.primary"]]); } if (mainmenu[playerid] == 7) { string currentLineCTSec = CTSecondary[currentLineIndex]; GunsMenu.HandlePreferenceSelection(player, CsTeam.CounterTerrorist, currentLineCTSec, RoundType.FullBuy); - player.PrintToChat($"{MessagePrefix} You selected {currentLineCTSec} as CT Secondary!"); + Print(player, Translator.Instance["guns_menu.weapon_selected",currentLineCTSec, Utils.TeamString(CsTeam.CounterTerrorist),Translator.Instance["weapon_type.secondary"]]); } if (mainmenu[playerid] == 8) { string currentLineCTPR = CTPistolRound[currentLineIndex]; GunsMenu.HandlePreferenceSelection(player, CsTeam.CounterTerrorist, currentLineCTPR); - player.PrintToChat($"{MessagePrefix} You selected {currentLineCTPR} as CT Pistol Round Weapon!"); + Print(player, Translator.Instance["guns_menu.weapon_selected",currentLineCTPR, Utils.TeamString(CsTeam.CounterTerrorist),Translator.Instance["roundtype.Pistol"]]); } if (mainmenu[playerid] == 9) @@ -284,12 +329,12 @@ public void OnTick() if (currentLineName == AWP[0]) { GunsMenu.HandlePreferenceSelection(player, CsTeam.Terrorist, CsItem.AWP.ToString(), remove: false); - player.PrintToChat($"{MessagePrefix} You selected '{currentLineName}' as when to give the AWP!"); + Print(player, Translator.Instance["guns_menu.awp_preference_selected",currentLineName]); } if (currentLineName == AWP[1]) { GunsMenu.HandlePreferenceSelection(player, CsTeam.Terrorist, CsItem.AWP.ToString(), remove: true); - player.PrintToChat($"{MessagePrefix} You selected '{currentLineName}' as when to give the AWP!"); + Print(player, Translator.Instance["guns_menu.awp_preference_selected",currentLineName]); } } @@ -311,6 +356,11 @@ public void OnTick() mainmenu[playerid] = 8; currentIndexDict[playerid] = 0; } + if (CTHalfBuy.Length > 0 && currentLineName == CTloadout[3]) + { + mainmenu[playerid] = 11; + currentIndexDict[playerid] = 0; + } } if (mainmenu[playerid] == 1) { @@ -330,6 +380,11 @@ public void OnTick() mainmenu[playerid] = 4; currentIndexDict[playerid] = 0; } + if (THalfBuy.Length > 0 && currentLineName == Tloadout[3]) + { + mainmenu[playerid] = 10; + currentIndexDict[playerid] = 0; + } } if (mainmenu[playerid] == 0) { @@ -403,6 +458,16 @@ public void OnTick() mainmenu[playerid] = 1; currentIndexDict[playerid] = 0; } + if (mainmenu[playerid] == 10) + { + mainmenu[playerid] = 1; + currentIndexDict[playerid] = 0; + } + if (mainmenu[playerid] == 11) + { + mainmenu[playerid] = 1; + currentIndexDict[playerid] = 0; + } if (mainmenu[playerid] == 6) { @@ -427,7 +492,7 @@ public void OnTick() } } buttonPressed[playerid] = true; - player.ExecuteClientCommand("play sounds/ui/item_sticker_select.vsnd_c"); + player.ExecuteClientCommand("play sounds/ui/menu_focus.vsnd_c"); } StringBuilder builder = new StringBuilder(); @@ -547,6 +612,38 @@ public void OnTick() } builder.AppendLine(BottomMenuOnpistol); } + if(mainmenu[playerid] == 10) + { + for (int i = 0; i < THalfBuy.Length; i++) + { + if (i == currentIndexDict[playerid]) + { + string lineHtml = $"{Imageleft} {THalfBuy[i]} {ImageRight}
"; + builder.AppendLine(lineHtml); + } + else + { + builder.AppendLine($"{THalfBuy[i]}
"); + } + } + builder.AppendLine(BottomMenu); + } + if(mainmenu[playerid] == 11) + { + for (int i = 0; i < CTHalfBuy.Length; i++) + { + if (i == currentIndexDict[playerid]) + { + string lineHtml = $"{Imageleft} {CTHalfBuy[i]} {ImageRight}
"; + builder.AppendLine(lineHtml); + } + else + { + builder.AppendLine($"{CTHalfBuy[i]}
"); + } + } + builder.AppendLine(BottomMenu); + } if(mainmenu[playerid] == 6) { diff --git a/RetakesAllocator/Menus/GunsMenu.cs b/RetakesAllocator/Menus/GunsMenu.cs index b305f90..0eed616 100644 --- a/RetakesAllocator/Menus/GunsMenu.cs +++ b/RetakesAllocator/Menus/GunsMenu.cs @@ -1,4 +1,4 @@ -using CounterStrikeSharp.API.Core; +using CounterStrikeSharp.API.Core; using CounterStrikeSharp.API.Modules.Entities.Constants; using CounterStrikeSharp.API.Modules.Menu; using CounterStrikeSharp.API.Modules.Utils; @@ -97,7 +97,7 @@ private void OpenTPrimaryMenu(CCSPlayerController player) menu.AddMenuOption(Translator.Instance["menu.exit"], OnSelectExit); - ChatMenus.OpenMenu(player, menu); + MenuManager.OpenChatMenu(player, menu); CreateMenuTimeoutTimer(player); } @@ -134,7 +134,7 @@ private void OpenTSecondaryMenu(CCSPlayerController player) menu.AddMenuOption(Translator.Instance["menu.exit"], OnSelectExit); - ChatMenus.OpenMenu(player, menu); + MenuManager.OpenChatMenu(player, menu); CreateMenuTimeoutTimer(player); } @@ -170,7 +170,7 @@ private void OpenCtPrimaryMenu(CCSPlayerController player) menu.AddMenuOption(Translator.Instance["menu.exit"], OnSelectExit); - ChatMenus.OpenMenu(player, menu); + MenuManager.OpenChatMenu(player, menu); CreateMenuTimeoutTimer(player); } @@ -206,7 +206,7 @@ private void OpenCtSecondaryMenu(CCSPlayerController player) menu.AddMenuOption(Translator.Instance["menu.exit"], OnSelectExit); - ChatMenus.OpenMenu(player, menu); + MenuManager.OpenChatMenu(player, menu); CreateMenuTimeoutTimer(player); } @@ -243,7 +243,7 @@ private void OpenTPistolMenu(CCSPlayerController player) menu.AddMenuOption(Translator.Instance["menu.exit"], OnSelectExit); - ChatMenus.OpenMenu(player, menu); + MenuManager.OpenChatMenu(player, menu); CreateMenuTimeoutTimer(player); } @@ -280,7 +280,7 @@ private void OpenCtPistolMenu(CCSPlayerController player) menu.AddMenuOption(Translator.Instance["menu.exit"], OnSelectExit); - ChatMenus.OpenMenu(player, menu); + MenuManager.OpenChatMenu(player, menu); CreateMenuTimeoutTimer(player); } @@ -316,7 +316,7 @@ private void OpenTHalfBuyMenu(CCSPlayerController player) menu.AddMenuOption(Translator.Instance["menu.exit"], OnSelectExit); - ChatMenus.OpenMenu(player, menu); + MenuManager.OpenChatMenu(player, menu); CreateMenuTimeoutTimer(player); } @@ -352,7 +352,7 @@ private void OpenCTHalfBuyMenu(CCSPlayerController player) menu.AddMenuOption(Translator.Instance["menu.exit"], OnSelectExit); - ChatMenus.OpenMenu(player, menu); + MenuManager.OpenChatMenu(player, menu); CreateMenuTimeoutTimer(player); } @@ -390,7 +390,7 @@ private void OpenGiveAwpMenu(CCSPlayerController player) menu.AddMenuOption(Translator.Instance["menu.exit"], OnSelectExit); - ChatMenus.OpenMenu(player, menu); + MenuManager.OpenChatMenu(player, menu); CreateMenuTimeoutTimer(player); } @@ -440,4 +440,4 @@ out _ ); Log.Debug(message); } -} \ No newline at end of file +} diff --git a/RetakesAllocator/Menus/MenuManager.cs b/RetakesAllocator/Menus/MenuManager.cs index 73adc96..ce4def6 100644 --- a/RetakesAllocator/Menus/MenuManager.cs +++ b/RetakesAllocator/Menus/MenuManager.cs @@ -2,7 +2,6 @@ using RetakesAllocator.Managers; using RetakesAllocator.Menus.Interfaces; using RetakesAllocatorCore; -using static RetakesAllocatorCore.PluginInfo; namespace RetakesAllocator.Menus; @@ -12,7 +11,7 @@ public enum MenuType NextRoundVote, } -public class MenuManager +public class AllocatorMenuManager { private readonly Dictionary _menus = new() { @@ -32,7 +31,7 @@ private bool MenuAlreadyOpenCheck(CCSPlayerController player) } public T GetMenu(MenuType menuType) - where T : AbstractBaseMenu + where T : AbstractBaseMenu { return (T) _menus[menuType]; } diff --git a/RetakesAllocator/Menus/VoteMenu.cs b/RetakesAllocator/Menus/VoteMenu.cs index 656c21d..6f7aeb4 100644 --- a/RetakesAllocator/Menus/VoteMenu.cs +++ b/RetakesAllocator/Menus/VoteMenu.cs @@ -1,4 +1,4 @@ -using CounterStrikeSharp.API.Core; +using CounterStrikeSharp.API.Core; using CounterStrikeSharp.API.Modules.Menu; using RetakesAllocator.Managers; using RetakesAllocator.Menus.Interfaces; @@ -32,7 +32,7 @@ public override void OpenMenu(CCSPlayerController player) menu.AddMenuOption(Translator.Instance["menu.exit"], OnSelectExit); - ChatMenus.OpenMenu(player, menu); + MenuManager.OpenChatMenu(player, menu); CreateMenuTimeoutTimer(player); } diff --git a/RetakesAllocator/RetakesAllocator.cs b/RetakesAllocator/RetakesAllocator.cs index 9588dc4..2e84042 100644 --- a/RetakesAllocator/RetakesAllocator.cs +++ b/RetakesAllocator/RetakesAllocator.cs @@ -1,3 +1,4 @@ +using System.Text; using System.Runtime.InteropServices; using CounterStrikeSharp.API; using CounterStrikeSharp.API.Core; @@ -9,6 +10,7 @@ using CounterStrikeSharp.API.Modules.Entities; using CounterStrikeSharp.API.Modules.Entities.Constants; using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions; +using CounterStrikeSharp.API.Modules.Timers; using CounterStrikeSharp.API.Modules.Utils; using RetakesAllocatorCore.Managers; using RetakesAllocator.Menus; @@ -31,14 +33,17 @@ public class RetakesAllocator : BasePlugin public override string ModuleAuthor => "Yoni Lerner, B3none, Gold KingZ"; public override string ModuleDescription => "https://github.com/yonilerner/cs2-retakes-allocator"; - private readonly MenuManager _menuManager = new(); + private readonly AllocatorMenuManager _allocatorMenuManager = new(); private readonly AdvancedGunMenu _advancedGunMenu = new(); private readonly Dictionary> _allocatedPlayerItems = new(); private IRetakesPluginEventSender? RetakesPluginEventSender { get; set; } - private CustomGameData CustomFunctions { get; set; } + private CustomGameData? CustomFunctions { get; set; } private bool IsAllocatingForRound { get; set; } + private string _bombsite = ""; + private bool _announceBombsite = false; + private bool _bombsiteAnnounceOneTime = false; #region Setup @@ -54,7 +59,10 @@ public override void Load(bool hotReload) RoundTypeManager.Instance.SetMap(mapName); }); - RegisterListener(OnTick); + if (Configs.GetConfigData().UseOnTickFeatures) + { + RegisterListener(OnTick); + } AddTimer(0.1f, () => { GetRetakesPluginEventSender().RetakesPluginEventHandlers += RetakesEventHandler; }); @@ -65,7 +73,7 @@ public override void Load(bool hotReload) CustomFunctions = new(); - if (Configs.GetConfigData().EnableCanAcquireHook) + if (Configs.GetConfigData().EnableCanAcquireHook && !Helpers.IsWindows()) { CustomFunctions.CCSPlayer_CanAcquireFunc.Hook(OnWeaponCanAcquire, HookMode.Pre); } @@ -90,6 +98,9 @@ private void ResetState(bool loadConfig = true) RoundTypeManager.Instance.Initialize(); _allocatedPlayerItems.Clear(); + _bombsite = ""; + _announceBombsite = false; + _bombsiteAnnounceOneTime = false; } private void HandleHotReload() @@ -105,7 +116,7 @@ public override void Unload(bool hotReload) GetRetakesPluginEventSender().RetakesPluginEventHandlers -= RetakesEventHandler; - if (Configs.GetConfigData().EnableCanAcquireHook) + if (Configs.GetConfigData().EnableCanAcquireHook && CustomFunctions != null) { CustomFunctions.CCSPlayer_CanAcquireFunc.Unhook(OnWeaponCanAcquire, HookMode.Pre); } @@ -163,7 +174,7 @@ public void OnNextRoundCommand(CCSPlayerController? player, CommandInfo commandI return; } - _menuManager.OpenMenuForPlayer(player!, MenuType.NextRoundVote); + _allocatorMenuManager.OpenMenuForPlayer(player!, MenuType.NextRoundVote); } [ConsoleCommand("css_gun")] @@ -316,9 +327,11 @@ public void OnReloadAllocatorConfigCommand(CCSPlayerController? player, CommandI public HookResult OnWeaponCanAcquire(DynamicHook hook) { + Log.Debug("OnWeaponCanAcquire"); // GetCSWeaponDataFromKeyFunc doesnt work on windows - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (Helpers.IsWindows()) { + Log.Debug("Exit early"); return HookResult.Continue; } @@ -352,6 +365,11 @@ HookResult RetStop() return HookResult.Stop; } + if (CustomFunctions is null) + { + return RetStop(); + } + var weaponData = CustomFunctions.GetCSWeaponDataFromKeyFunc.Invoke(-1, hook.GetParam(1).ItemDefinitionIndex.ToString()); @@ -375,6 +393,11 @@ HookResult RetStop() return Configs.GetConfigData().ZeusPreference == ZeusPreference.Always ? HookResult.Continue : RetStop(); } + if (!WeaponHelpers.IsUsableWeapon(item)) + { + return RetStop(); + } + var isPreferred = WeaponHelpers.IsPreferred(team, item); var purchasedAllocationType = RoundTypeManager.Instance.GetCurrentRoundType() is not null ? WeaponHelpers.GetWeaponAllocationTypeForWeaponAndRound( @@ -572,7 +595,7 @@ private void HandleAllocateEvent() Log.Debug("Handling allocate event"); Server.ExecuteCommand("mp_max_armor 0"); - var menu = _menuManager.GetMenu(MenuType.NextRoundVote); + var menu = _allocatorMenuManager.GetMenu(MenuType.NextRoundVote); menu.GatherAndHandleVotes(); var allPlayers = Utilities.GetPlayers() @@ -616,13 +639,183 @@ out var currentRoundType public void OnTick() { - _advancedGunMenu.OnTick(); + if (!string.IsNullOrEmpty(Configs.GetConfigData().InGameGunMenuCenterCommands)) + { + _advancedGunMenu.OnTick(); + } + + if (_announceBombsite) + { + var playerEntities = Utilities.FindAllEntitiesByDesignerName("cs_player_controller"); + var countct = Utilities.GetPlayers() + .Count(p => p.TeamNum == (int) CsTeam.CounterTerrorist && p.PawnIsAlive && !p.IsHLTV); + var countt = Utilities.GetPlayers() + .Count(p => p.TeamNum == (int) CsTeam.Terrorist && p.PawnIsAlive && !p.IsHLTV); + string Image = _bombsite == "A" ? Translator.Instance["BombSite.A"] : + _bombsite == "B" ? Translator.Instance["BombSite.B"] : ""; + foreach (var player in playerEntities) + { + if (player == null || !player.IsValid || !player.PawnIsAlive || player.IsBot || player.IsHLTV) continue; + + if (player.TeamNum == (byte) CsTeam.Terrorist && + !Configs.GetConfigData().BombSiteAnnouncementCenterToCTOnly) + { + StringBuilder builder = new StringBuilder(); + builder.AppendFormat(Localizer["T.Message"], _bombsite, Image, countt, countct); + var centerhtml = builder.ToString(); + player?.PrintToCenterHtml(centerhtml); + } + else if (player.TeamNum == (byte) CsTeam.CounterTerrorist) + { + StringBuilder builder = new StringBuilder(); + builder.AppendFormat(Localizer["CT.Message"], _bombsite, Image, countt, countct); + var centerhtml = builder.ToString(); + player?.PrintToCenterHtml(centerhtml); + } + } + } + } + + [GameEventHandler(HookMode.Pre)] + public HookResult OnEventBombPlanted(EventBombPlanted @event, GameEventInfo info) + { + if (@event == null) return HookResult.Continue; + + if (Configs.GetConfigData().DisableDefaultBombPlantedCenterMessage) + { + info.DontBroadcast = true; + } + + if (Configs.GetConfigData().ForceCloseBombSiteAnnouncementCenterOnPlant) + { + _bombsite = ""; + _announceBombsite = false; + } + + return HookResult.Continue; + } + + [GameEventHandler] + public HookResult OnEventRoundStart(EventRoundStart @event, GameEventInfo info) + { + if (@event == null) return HookResult.Continue; + _bombsiteAnnounceOneTime = false; + return HookResult.Continue; } + [GameEventHandler] + public HookResult OnEventRoundEnd(EventRoundEnd @event, GameEventInfo info) + { + if (@event == null) return HookResult.Continue; + _bombsite = ""; + _announceBombsite = false; + return HookResult.Continue; + } + + [GameEventHandler] + public HookResult OnEventEnterBombzone(EventEnterBombzone @event, GameEventInfo info) + { + if (@event == null || Helpers.IsWarmup() || _bombsiteAnnounceOneTime) return HookResult.Continue; + + var player = @event.Userid; + if (player == null || !player.IsValid || player.TeamNum != (byte) CsTeam.Terrorist) return HookResult.Continue; + + var playerPawn = player.PlayerPawn; + if (playerPawn == null || !playerPawn.IsValid) return HookResult.Continue; + + var playerPosition = playerPawn.Value!.AbsOrigin; + + foreach (var entity in Utilities.FindAllEntitiesByDesignerName("info_bomb_target")) + { + var entityPosition = entity.AbsOrigin; + if (entityPosition != null) + { + var distanceVector = playerPosition! - entityPosition; + var distance = distanceVector.Length(); + float thresholdDistance = 400.0f; + + if (distance <= thresholdDistance) + { + if (entity.DesignerName == "info_bomb_target_hint_A") + { + _bombsite = "A"; + if (Configs.GetConfigData().EnableBombSiteAnnouncementCenter) + { + Server.NextFrame(() => + { + AddTimer(Configs.GetConfigData().BombSiteAnnouncementCenterDelay, () => + { + _bombsiteAnnounceOneTime = true; + _announceBombsite = true; + AddTimer(Configs.GetConfigData().BombSiteAnnouncementCenterShowTimer, () => + { + _bombsite = ""; + _announceBombsite = false; + }, TimerFlags.STOP_ON_MAPCHANGE); + }, TimerFlags.STOP_ON_MAPCHANGE); + }); + } + + if (Configs.GetConfigData().EnableBombSiteAnnouncementChat) + { + Server.PrintToChatAll(Localizer["chatAsite.line1"]); + Server.PrintToChatAll(Localizer["chatAsite.line2"]); + Server.PrintToChatAll(Localizer["chatAsite.line3"]); + Server.PrintToChatAll(Localizer["chatAsite.line4"]); + Server.PrintToChatAll(Localizer["chatAsite.line5"]); + Server.PrintToChatAll(Localizer["chatAsite.line6"]); + } + + break; + } + else if (entity.DesignerName == "info_bomb_target_hint_B") + { + _bombsite = "B"; + if (Configs.GetConfigData().EnableBombSiteAnnouncementCenter) + { + Server.NextFrame(() => + { + AddTimer(Configs.GetConfigData().BombSiteAnnouncementCenterDelay, () => + { + _bombsiteAnnounceOneTime = true; + _announceBombsite = true; + AddTimer(Configs.GetConfigData().BombSiteAnnouncementCenterShowTimer, () => + { + _bombsite = ""; + _announceBombsite = false; + }, TimerFlags.STOP_ON_MAPCHANGE); + }, TimerFlags.STOP_ON_MAPCHANGE); + }); + } + + if (Configs.GetConfigData().EnableBombSiteAnnouncementChat) + { + Server.PrintToChatAll(Localizer["chatBsite.line1"]); + Server.PrintToChatAll(Localizer["chatBsite.line2"]); + Server.PrintToChatAll(Localizer["chatBsite.line3"]); + Server.PrintToChatAll(Localizer["chatBsite.line4"]); + Server.PrintToChatAll(Localizer["chatBsite.line5"]); + Server.PrintToChatAll(Localizer["chatBsite.line6"]); + } + + break; + } + } + } + } + + return HookResult.Continue; + } + + [GameEventHandler] public HookResult OnEventPlayerDisconnect(EventPlayerDisconnect @event, GameEventInfo info) { - _advancedGunMenu.OnEventPlayerDisconnect(@event, info); + if (!string.IsNullOrEmpty(Configs.GetConfigData().InGameGunMenuCenterCommands)) + { + _advancedGunMenu.OnEventPlayerDisconnect(@event, info); + } + return HookResult.Continue; } @@ -630,9 +823,12 @@ public HookResult OnEventPlayerDisconnect(EventPlayerDisconnect @event, GameEven public HookResult OnEventPlayerChat(EventPlayerChat @event, GameEventInfo info) { if (@event == null) return HookResult.Continue; - _advancedGunMenu.OnEventPlayerChat(@event, info); - if (string.IsNullOrEmpty(Configs.GetConfigData().InGameGunMenuChatCommands)) return HookResult.Continue; + if (!string.IsNullOrEmpty(Configs.GetConfigData().InGameGunMenuCenterCommands)) + { + _advancedGunMenu.OnEventPlayerChat(@event, info); + } + var eventplayer = @event.Userid; var eventmessage = @event.Text; var player = Utilities.GetPlayerFromUserid(eventplayer); @@ -643,13 +839,18 @@ public HookResult OnEventPlayerChat(EventPlayerChat @event, GameEventInfo info) if (string.IsNullOrWhiteSpace(eventmessage)) return HookResult.Continue; string trimmedMessageStart = eventmessage.TrimStart(); string message = trimmedMessageStart.TrimEnd(); - string[] ChatMenuCommands = Configs.GetConfigData().InGameGunMenuChatCommands.Split(','); - if (ChatMenuCommands.Any(cmd => cmd.Equals(message, StringComparison.OrdinalIgnoreCase))) + if (!string.IsNullOrEmpty(Configs.GetConfigData().InGameGunMenuChatCommands)) { - _menuManager.OpenMenuForPlayer(player!, MenuType.Guns); + string[] ChatMenuCommands = Configs.GetConfigData().InGameGunMenuChatCommands.Split(','); + + if (ChatMenuCommands.Any(cmd => cmd.Equals(message, StringComparison.OrdinalIgnoreCase))) + { + _allocatorMenuManager.OpenMenuForPlayer(player!, MenuType.Guns); + } } + return HookResult.Continue; } @@ -711,7 +912,7 @@ private void AllocateItemsForPlayer(CCSPlayerController player, ICollection", "menu.right.image": "", "menu.bottom.text": "
[ WASD - To Native ]
[ - To Exit ]
", - "menu.bottom.text.pistol": "[ - To Exit ]
" + "menu.bottom.text.pistol": "[ - To Exit ]
", + + "BombSite.A": "", + "BombSite.B": "", + "T.Message": "DEFEND SITE {0}
{1}
{2} T vs. {3} CT", + "CT.Message": "RETAKE SITE {0}
{1}
{2} T vs. {3} CT", + + "chatAsite.line1": "{DarkBlue}[Retakes] {Yellow} ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎回︎回︎回︎回︎", + "chatAsite.line2": "{DarkBlue}[Retakes] {Yellow} 回︎回︎‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎回︎回︎", + "chatAsite.line3": "{DarkBlue}[Retakes] {Yellow} 回︎回︎‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‎‏‏‎ ‎‏‏‎ ‎‏‏‎ 回︎回︎", + "chatAsite.line4": "{DarkBlue}[Retakes] {Yellow} 回︎回︎回︎回︎回︎回︎", + "chatAsite.line5": "{DarkBlue}[Retakes] {Yellow} 回︎回︎‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‎‏‏‎ ‎‏‏‎ ‎‏‏‎ 回︎回︎", + "chatAsite.line6": "{DarkBlue}[Retakes] {Yellow} 回︎回︎‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‎‏‏‎ ‎‏‏‎ ‎‏‏‎ 回︎回︎", + + "chatBsite.line1": "{DarkBlue}[Retakes] {Yellow} 回︎回︎回︎回︎", + "chatBsite.line2": "{DarkBlue}[Retakes] {Yellow} 回︎回︎‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‎‏‏‎ ‎‏‏‎ ‎‏‏‎回︎", + "chatBsite.line3": "{DarkBlue}[Retakes] {Yellow} 回︎回︎回︎回︎", + "chatBsite.line4": "{DarkBlue}[Retakes] {Yellow} 回︎回︎‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‎‏‏‎ ‎‏‏‎ 回︎", + "chatBsite.line5": "{DarkBlue}[Retakes] {Yellow} 回︎回︎‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‏‏‎ ‎‎‏‏‎ ‎‏‏‎ 回︎", + "chatBsite.line6": "{DarkBlue}[Retakes] {Yellow} 回︎回︎回︎回︎" } diff --git a/RetakesAllocatorCore/Config/Configs.cs b/RetakesAllocatorCore/Config/Configs.cs index f90cd9f..a8b22fd 100644 --- a/RetakesAllocatorCore/Config/Configs.cs +++ b/RetakesAllocatorCore/Config/Configs.cs @@ -213,8 +213,16 @@ public Dictionary< public bool MigrateOnStartup { get; set; } = true; public bool ResetStateOnGameRestart { get; set; } = true; public bool AllowAllocationAfterFreezeTime { get; set; } = true; + public bool UseOnTickFeatures { get; set; } = true; public bool EnableRoundTypeAnnouncement { get; set; } = true; public bool EnableRoundTypeAnnouncementCenter { get; set; } = false; + public bool EnableBombSiteAnnouncementCenter { get; set; } = false; + public bool BombSiteAnnouncementCenterToCTOnly { get; set; } = false; + public bool DisableDefaultBombPlantedCenterMessage { get; set; } = false; + public bool ForceCloseBombSiteAnnouncementCenterOnPlant { get; set; } = true; + public float BombSiteAnnouncementCenterDelay { get; set; } = 1.0f; + public float BombSiteAnnouncementCenterShowTimer { get; set; } = 5.0f; + public bool EnableBombSiteAnnouncementChat { get; set; } = false; public bool EnableNextRoundTypeVoting { get; set; } = false; public int NumberOfExtraVipChancesForPreferredWeapon { get; set; } = 1; public bool AllowPreferredWeaponForEveryone { get; set; } = false; @@ -238,7 +246,10 @@ public Dictionary< public LogLevel LogLevel { get; set; } = LogLevel.Information; public string ChatMessagePluginName { get; set; } = "Retakes"; public string? ChatMessagePluginPrefix { get; set; } - public string InGameGunMenuCenterCommands { get; set; } = "gunsmenu,gunmenu,!gunmenu,!gunsmenu,!menugun,!menuguns,/gunsmenu,/gunmenu"; + + public string InGameGunMenuCenterCommands { get; set; } = + "gunsmenu,gunmenu,!gunmenu,!gunsmenu,!menugun,!menuguns,/gunsmenu,/gunmenu"; + public string InGameGunMenuChatCommands { get; set; } = "guns,!guns,/guns"; public ZeusPreference ZeusPreference { get; set; } = ZeusPreference.Never; @@ -326,4 +337,4 @@ public bool CanAssignDefaultWeapons() { return AllowedWeaponSelectionTypes.Contains(WeaponSelectionType.Default); } -} \ No newline at end of file +} diff --git a/RetakesAllocatorCore/OnWeaponCommandHelper.cs b/RetakesAllocatorCore/OnWeaponCommandHelper.cs index e62d592..7d236c7 100644 --- a/RetakesAllocatorCore/OnWeaponCommandHelper.cs +++ b/RetakesAllocatorCore/OnWeaponCommandHelper.cs @@ -7,7 +7,6 @@ namespace RetakesAllocatorCore; public class OnWeaponCommandHelper { - public static string Handle(ICollection args, ulong userId, RoundType? roundType, CsTeam currentTeam, bool remove, out CsItem? outWeapon) { @@ -16,7 +15,8 @@ public static string Handle(ICollection args, ulong userId, RoundType? r return result.Item1; } - public static async Task> HandleAsync (ICollection args, ulong userId, RoundType? roundType, CsTeam currentTeam, + public static async Task> HandleAsync(ICollection args, ulong userId, + RoundType? roundType, CsTeam currentTeam, bool remove) { CsItem? outWeapon = null; @@ -33,9 +33,13 @@ public static string Handle(ICollection args, ulong userId, RoundType? r var gunsMessage = Translator.Instance[ "weapon_preference.gun_usage", currentTeam, - string.Join(", ", WeaponHelpers.GetPossibleWeaponsForAllocationType(WeaponAllocationType.PistolRound, currentTeam)), - string.Join(", ", WeaponHelpers.GetPossibleWeaponsForAllocationType(WeaponAllocationType.HalfBuyPrimary, currentTeam)), - string.Join(", ", WeaponHelpers.GetPossibleWeaponsForAllocationType(WeaponAllocationType.FullBuyPrimary, currentTeam)) + string.Join(", ", + WeaponHelpers.GetPossibleWeaponsForAllocationType(WeaponAllocationType.PistolRound, currentTeam)), + string.Join(", ", + WeaponHelpers.GetPossibleWeaponsForAllocationType(WeaponAllocationType.HalfBuyPrimary, + currentTeam)), + string.Join(", ", + WeaponHelpers.GetPossibleWeaponsForAllocationType(WeaponAllocationType.FullBuyPrimary, currentTeam)) ]; return Ret(gunsMessage); } @@ -109,14 +113,14 @@ roundType is not null && { if (isPreferred) { - await Queries.SetPreferredWeaponPreferenceAsync(userId, null); return Ret(Translator.Instance["weapon_preference.unset_preference_preferred", weapon]); } else { await Queries.SetWeaponPreferenceForUserAsync(userId, team, allocationType.Value, null); - return Ret(Translator.Instance["weapon_preference.unset_preference", weapon, allocationType.Value, team]); + return Ret( + Translator.Instance["weapon_preference.unset_preference", weapon, allocationType.Value, team]); } } diff --git a/RetakesAllocatorCore/PluginInfo.cs b/RetakesAllocatorCore/PluginInfo.cs index 2456f29..68d1e2e 100644 --- a/RetakesAllocatorCore/PluginInfo.cs +++ b/RetakesAllocatorCore/PluginInfo.cs @@ -5,7 +5,7 @@ namespace RetakesAllocatorCore; public static class PluginInfo { - public const string Version = "2.3.7"; + public const string Version = "2.3.8"; public static readonly string LogPrefix = $"[RetakesAllocator {Version}] ";