diff --git a/vMenu/EventManager.cs b/vMenu/EventManager.cs index 99a091ca..682c6825 100644 --- a/vMenu/EventManager.cs +++ b/vMenu/EventManager.cs @@ -200,6 +200,7 @@ private void SetWhiteLists() // reset addons VehicleSpawner.WhitelistVehicles = new Dictionary(); PlayerAppearance.WhitelistedPeds = new Dictionary(); + WeaponOptions.WeaponWhitelist = new Dictionary(); var jsonData = LoadResourceFile(GetCurrentResourceName(), "config/model-whitelists.json") ?? "{}"; try @@ -238,6 +239,22 @@ private void SetWhiteLists() } } } + + // load whitelisted weapon. + if (whitelists.ContainsKey("whitelistedweapons")) + { + foreach (var whitelist in whitelists["whitelistedweapons"]) + { + if (!WeaponOptions.WeaponWhitelist.ContainsKey(whitelist)) + { + WeaponOptions.WeaponWhitelist.Add(whitelist, Game.GenerateHashASCII(whitelist)); + } + else + { + Debug.WriteLine($"[vMenu] [Error] Your model-whitelists.json file contains 2 or more entries with the same ped name! ({whitelist}) Please remove duplicate lines!"); + } + } + } } catch (JsonReaderException ex) { diff --git a/vMenu/FunctionsController.cs b/vMenu/FunctionsController.cs index 69918619..2f49a9e7 100644 --- a/vMenu/FunctionsController.cs +++ b/vMenu/FunctionsController.cs @@ -76,6 +76,7 @@ public void SetupTickFunctions() Tick += MiscSettings; Tick += GeneralTasks; Tick += GcTick; + Tick += ControllerTick; if (GetSettingsBool(Setting.keep_player_head_props)) { @@ -214,6 +215,36 @@ private async Task GcTick() } #endregion + #region Controller tick and functions + private async Task ControllerTick() + { + if (!Game.IsPaused && !IsPauseMenuRestarting() && IsScreenFadedIn() && !IsPlayerSwitchInProgress() && !Game.Player.IsDead && !MenuController.DisableMenuButtons) + { + if (Game.CurrentInputMode == InputMode.GamePad) + { + await HandleMenuToggleKeyForController(); + } + } + await Task.FromResult(0); + } + private async Task HandleMenuToggleKeyForController() + { + int tmpTimer = GetGameTimer(); + while ((Game.IsControlPressed(0, Control.InteractionMenu) || Game.IsDisabledControlPressed(0, Control.InteractionMenu)) && !Game.IsPaused && IsScreenFadedIn() && !Game.Player.IsDead && !IsPlayerSwitchInProgress() && !MenuController.DontOpenAnyMenu) + { + if (GetGameTimer() - tmpTimer > 400) + { + if (MainMenu.Menu != null) + { + MainMenu.Menu.OpenMenu(); + } + break; + } + await Delay(0); + } + } + #endregion + #region General Tasks /// /// All general tasks that run every 1 game ticks (and are not (sub)menu specific). diff --git a/vMenu/menus/WeaponOptions.cs b/vMenu/menus/WeaponOptions.cs index e9415ecf..bf42e9aa 100644 --- a/vMenu/menus/WeaponOptions.cs +++ b/vMenu/menus/WeaponOptions.cs @@ -23,6 +23,7 @@ public class WeaponOptions public bool UnlimitedParachutes { get; private set; } = UserDefaults.WeaponsUnlimitedParachutes; public static Dictionary AddonWeapons = new(); + public static Dictionary WeaponWhitelist = new(); private Dictionary weaponInfo; private Dictionary addonWeaponInfo; diff --git a/vMenuServer/MainServer.cs b/vMenuServer/MainServer.cs index 9f5e6ee4..8b351ba1 100644 --- a/vMenuServer/MainServer.cs +++ b/vMenuServer/MainServer.cs @@ -1213,11 +1213,11 @@ private void SetupAddonPerms(Dictionary> whitelists, Dictio { if (whitelists.ContainsKey("whitelistedweapons")) { - foreach (var addon in whitelists["whitelistedweapons"]) + foreach (var whitelist in whitelists["whitelistedweapons"]) { - if (!SupplementaryPermissionManager.Permission.Contains("WW" + addon.ToLower().Replace("weapon_", ""))) + if (!SupplementaryPermissionManager.Permission.Contains("WW" + whitelist.ToLower().Replace("weapon_", ""))) { - SupplementaryPermissionManager.Permission.Add("WW" + addon.ToLower().Replace("weapon_", "")); + SupplementaryPermissionManager.Permission.Add("WW" + whitelist.ToLower().Replace("weapon_", "")); } } }