diff --git a/SharedClasses/PermissionsManager.cs b/SharedClasses/PermissionsManager.cs index 1f2b6ced..4f00c165 100644 --- a/SharedClasses/PermissionsManager.cs +++ b/SharedClasses/PermissionsManager.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/vMenu/MainMenu.cs b/vMenu/MainMenu.cs index b4b96e81..363d16bb 100644 --- a/vMenu/MainMenu.cs +++ b/vMenu/MainMenu.cs @@ -391,62 +391,68 @@ private static void PostPermissionsSetup() break; } - if ((IsAllowed(Permission.Staff) && GetSettingsBool(Setting.vmenu_menu_staff_only)) || GetSettingsBool(Setting.vmenu_menu_staff_only) == false) + bool canUseMenu() { - if (GetSettingsInt(Setting.vmenu_menu_toggle_key) != -1) - { - MenuToggleKey = (Control)GetSettingsInt(Setting.vmenu_menu_toggle_key); - //MenuToggleKey = GetSettingsInt(Setting.vmenu_menu_toggle_key); - } - if (GetSettingsInt(Setting.vmenu_noclip_toggle_key) != -1) - { - NoClipKey = GetSettingsInt(Setting.vmenu_noclip_toggle_key); - } + if (GetSettingsBool(Setting.vmenu_menu_staff_only) == false) return true; + else if (IsAllowed(Permission.Staff)) return true; + return false; + } - // Create the main menu. - Menu = new Menu(Game.Player.Name, "Main Menu"); - PlayerSubmenu = new Menu(Game.Player.Name, "Player Related Options"); - VehicleSubmenu = new Menu(Game.Player.Name, "Vehicle Related Options"); - WorldSubmenu = new Menu(Game.Player.Name, "World Options"); + if (!canUseMenu()) + { + MenuController.MainMenu = null; + MenuController.DisableMenuButtons = true; + MenuController.DontOpenAnyMenu = true; + MenuController.MenuToggleKey = (Control)(-1); // disables the menu toggle key + return; + } - // Add the main menu to the menu pool. - MenuController.AddMenu(Menu); - MenuController.MainMenu = Menu; + if (GetSettingsInt(Setting.vmenu_menu_toggle_key) != -1) + { + MenuToggleKey = (Control)GetSettingsInt(Setting.vmenu_menu_toggle_key); + //MenuToggleKey = GetSettingsInt(Setting.vmenu_menu_toggle_key); + } + if (GetSettingsInt(Setting.vmenu_noclip_toggle_key) != -1) + { + NoClipKey = GetSettingsInt(Setting.vmenu_noclip_toggle_key); + } - MenuController.AddSubmenu(Menu, PlayerSubmenu); - MenuController.AddSubmenu(Menu, VehicleSubmenu); - MenuController.AddSubmenu(Menu, WorldSubmenu); + // Create the main menu. + Menu = new Menu(Game.Player.Name, "Main Menu"); + PlayerSubmenu = new Menu(Game.Player.Name, "Player Related Options"); + VehicleSubmenu = new Menu(Game.Player.Name, "Vehicle Related Options"); + WorldSubmenu = new Menu(Game.Player.Name, "World Options"); - // Create all (sub)menus. - CreateSubmenus(); + // Add the main menu to the menu pool. + MenuController.AddMenu(Menu); + MenuController.MainMenu = Menu; - if (!GetSettingsBool(Setting.vmenu_disable_player_stats_setup)) - { - // Manage Stamina - if (PlayerOptionsMenu != null && PlayerOptionsMenu.PlayerStamina && IsAllowed(Permission.POUnlimitedStamina)) - StatSetInt((uint)GetHashKey("MP0_STAMINA"), 100, true); - else - StatSetInt((uint)GetHashKey("MP0_STAMINA"), 0, true); - - // Manage other stats, in order of appearance in the pause menu (stats) page. - StatSetInt((uint)GetHashKey("MP0_SHOOTING_ABILITY"), 100, true); // Shooting - StatSetInt((uint)GetHashKey("MP0_STRENGTH"), 100, true); // Strength - StatSetInt((uint)GetHashKey("MP0_STEALTH_ABILITY"), 100, true); // Stealth - StatSetInt((uint)GetHashKey("MP0_FLYING_ABILITY"), 100, true); // Flying - StatSetInt((uint)GetHashKey("MP0_WHEELIE_ABILITY"), 100, true); // Driving - StatSetInt((uint)GetHashKey("MP0_LUNG_CAPACITY"), 100, true); // Lung Capacity - StatSetFloat((uint)GetHashKey("MP0_PLAYER_MENTAL_STATE"), 0f, true); // Mental State - } + MenuController.AddSubmenu(Menu, PlayerSubmenu); + MenuController.AddSubmenu(Menu, VehicleSubmenu); + MenuController.AddSubmenu(Menu, WorldSubmenu); - TriggerEvent("vMenu:SetupTickFunctions"); - } - else + // Create all (sub)menus. + CreateSubmenus(); + + if (!GetSettingsBool(Setting.vmenu_disable_player_stats_setup)) { - MenuController.MainMenu = null; - MenuController.DisableMenuButtons = true; - MenuController.DontOpenAnyMenu = true; - MenuController.MenuToggleKey = (Control)(-1); // disables the menu toggle key + // Manage Stamina + if (PlayerOptionsMenu != null && PlayerOptionsMenu.PlayerStamina && IsAllowed(Permission.POUnlimitedStamina)) + StatSetInt((uint)GetHashKey("MP0_STAMINA"), 100, true); + else + StatSetInt((uint)GetHashKey("MP0_STAMINA"), 0, true); + + // Manage other stats, in order of appearance in the pause menu (stats) page. + StatSetInt((uint)GetHashKey("MP0_SHOOTING_ABILITY"), 100, true); // Shooting + StatSetInt((uint)GetHashKey("MP0_STRENGTH"), 100, true); // Strength + StatSetInt((uint)GetHashKey("MP0_STEALTH_ABILITY"), 100, true); // Stealth + StatSetInt((uint)GetHashKey("MP0_FLYING_ABILITY"), 100, true); // Flying + StatSetInt((uint)GetHashKey("MP0_WHEELIE_ABILITY"), 100, true); // Driving + StatSetInt((uint)GetHashKey("MP0_LUNG_CAPACITY"), 100, true); // Lung Capacity + StatSetFloat((uint)GetHashKey("MP0_PLAYER_MENTAL_STATE"), 0f, true); // Mental State } + + TriggerEvent("vMenu:SetupTickFunctions"); } ///