fix(es_extended/server/main): skip unknown weapons when loading a loadout - #1816
Closed
seltonmt012 wants to merge 1 commit into
Closed
fix(es_extended/server/main): skip unknown weapons when loading a loadout#1816seltonmt012 wants to merge 1 commit into
seltonmt012 wants to merge 1 commit into
Conversation
…dout 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.
Author
|
Got an answer on Discord: contributions should target the branch that becomes the next release, so |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A player whose saved loadout contains a weapon that is not in
Config.Weaponscan never log in again.loadESXPlayerwalks the stored loadout like this:ESX.GetWeaponLabelasserts when the name is unknown, so it never returns a falsy value and theif label thencheck can never skip anything. The assert propagates out ofloadESXPlayer, soCreateExtendedPlayeris never reached,ESX.Players[playerId]stays empty andesx:playerLoadednever fires. The player sits on the loading screen and hits the same error on every reconnect, with no way out other than editing the database.This is reachable whenever the weapon list changes underneath saved data — changing
sv_enforceGameBuild, removing or renaming an entry inshared/weapons.lua, or removing a resource that had added weapons to the config.Wrapping the lookup leaves
ESX.GetWeaponLabeluntouched and lets the existing check do what it was written for.Tested locally on artifact 25770 with MariaDB by storing
{"WEAPON_NOTAREALGUN":{"ammo":50}}in a character's loadout column:before: the client hangs after character selection, server logs
Invalid weapon name!with a stack trace throughGetWeaponLabelandloadESXPlayerafter: the character loads normally, the unknown weapon is skipped and no error is logged
My commit messages and PR title follow the Conventional Commits standard.
My changes have been tested locally and function as expected.
My PR does not introduce any breaking changes.
I have provided a clear explanation of what my PR does, including the reasoning behind the changes and any relevant context.