mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-28 23:01:26 +00:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user