Skip to content
Open
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
9 changes: 7 additions & 2 deletions vMenu/CommonFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
Expand All @@ -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);
Expand Down