Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions vMenu/EventManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ private void SetWhiteLists()
// reset addons
VehicleSpawner.WhitelistVehicles = new Dictionary<string, uint>();
PlayerAppearance.WhitelistedPeds = new Dictionary<string, uint>();
WeaponOptions.WeaponWhitelist = new Dictionary<string, uint>();

var jsonData = LoadResourceFile(GetCurrentResourceName(), "config/model-whitelists.json") ?? "{}";
try
Expand Down Expand Up @@ -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)
{
Expand Down
31 changes: 31 additions & 0 deletions vMenu/FunctionsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public void SetupTickFunctions()
Tick += MiscSettings;
Tick += GeneralTasks;
Tick += GcTick;
Tick += ControllerTick;

if (GetSettingsBool(Setting.keep_player_head_props))
{
Expand Down Expand Up @@ -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
/// <summary>
/// All general tasks that run every 1 game ticks (and are not (sub)menu specific).
Expand Down
1 change: 1 addition & 0 deletions vMenu/menus/WeaponOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class WeaponOptions
public bool UnlimitedParachutes { get; private set; } = UserDefaults.WeaponsUnlimitedParachutes;

public static Dictionary<string, uint> AddonWeapons = new();
public static Dictionary<string, uint> WeaponWhitelist = new();

private Dictionary<Menu, ValidWeapon> weaponInfo;
private Dictionary<Menu, ValidAddonWeapon> addonWeaponInfo;
Expand Down
6 changes: 3 additions & 3 deletions vMenuServer/MainServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1213,11 +1213,11 @@ private void SetupAddonPerms(Dictionary<string, List<string>> 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_", ""));
}
}
}
Expand Down
Loading