From a634940656f308c5693fe9df647b428cbb6b6f6f Mon Sep 17 00:00:00 2001 From: saber2k <138956946+saber9k@users.noreply.github.com> Date: Sun, 5 Jul 2026 02:37:24 -0400 Subject: [PATCH] fix: saved weapon loadout permissions Loadouts weren't checking weapon permissions at all. It passed ignoreSettingsAndPerms=true, Permission enum values change as new weapons are added, so, a loadout saved by an older vMenu build could deserialize to the wrong permission. Resolve permissions fresh from the weapon's SpawnName instead of using the saved value. --- vMenu/CommonFunctions.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vMenu/CommonFunctions.cs b/vMenu/CommonFunctions.cs index cbf2e802..84ae2fb0 100644 --- a/vMenu/CommonFunctions.cs +++ b/vMenu/CommonFunctions.cs @@ -2825,9 +2825,14 @@ public static async Task SpawnWeaponLoadoutAsync(string saveName, bool appendWea { Game.PlayerPed.Weapons.RemoveAll(); } + + // Resolve permission by weapon name instead of using the saved Perm value. + // Permission enum values change as new weapons are added, so an old saved loadout can deserialize to the wrong permission. + Permission ResolveCurrentPerm(ValidWeapon wp) => + ValidWeapons.weaponPermissions.TryGetValue(wp.SpawnName, out var p) ? p : Permission.WPSpawn; // Check if any weapon is not allowed. - if (!ignoreSettingsAndPerms && loadout.Any((wp) => !IsAllowed(wp.Perm))) + if (loadout.Any((wp) => !IsAllowed(ResolveCurrentPerm(wp)))) { Notify.Alert("One or more weapon(s) in this saved loadout are not allowed on this server. Those weapons will not be loaded."); } @@ -2842,7 +2847,7 @@ public static async Task SpawnWeaponLoadoutAsync(string saveName, bool appendWea continue; } - if (ignoreSettingsAndPerms || IsAllowed(w.Perm)) + if (IsAllowed(ResolveCurrentPerm(w))) { // Give the weapon GiveWeaponToPed(Game.PlayerPed.Handle, w.Hash, w.CurrentAmmo > -1 ? w.CurrentAmmo : w.GetMaxAmmo, false, false);