fix(es_extended/server/main): skip unknown weapons when loading a loadout

ESX.GetWeaponLabel asserts on a name that is not in Config.Weapons, so it
never returns a falsy value and the `if label then` check below it can never
skip anything. The assert propagates out of loadESXPlayer, which means the
player object is never created and esx:playerLoaded never fires - the player
is stuck on the loading screen and hits the same error on every reconnect.

This happens whenever a saved loadout holds a weapon the config no longer
knows, for example after changing sv_enforceGameBuild or after removing a
weapon from shared/weapons.lua.

Wrapping the lookup keeps GetWeaponLabel itself untouched and lets the
existing check do what it was written for.
This commit is contained in:
Selt
2026-07-27 03:07:15 +02:00
parent ca597cf6f4
commit 49c31bcb61
+2 -2
View File
@@ -288,9 +288,9 @@ function loadESXPlayer(identifier, playerId, isNew)
local loadout = json.decode(result.loadout)
for name, weapon in pairs(loadout) do
local label = ESX.GetWeaponLabel(name)
local found, label = pcall(ESX.GetWeaponLabel, name)
if label then
if found and label then
userData.loadout[#userData.loadout + 1] = {
name = name,
ammo = weapon.ammo,