fix(esx_license): always answer the callback - #134
Open
seltonmt012 wants to merge 1 commit into
Open
Conversation
getLicense, getLicenses and checkLicense only call cb inside the branch that
found an xPlayer. When ESX.Player returns nil the handler ends without ever
answering, and ESX.TriggerServerCallback on the client waits for a reply that
never comes. The player gets no menu, no error and no second chance until they
trigger the interaction again.
It is reachable: esx_boat, esx_weaponshop, esx_vehicleshop and esx_drugs all
pass their own server id as the target, and that id has no xPlayer yet during
the loading window or while a character switch is in flight.
Each branch now answers with the shape its success path uses: nil for the
single license, an empty list for getLicenses, and false for checkLicense, so
a shop keeps treating an unknown player as unlicensed instead of hanging.
Driven against the shipped file with ESX.Player stubbed to nil: before, the
three callbacks never fire. After, they answer cb(nil), cb({}) and cb(false).
getLicensesList never had the guard and is unchanged in both runs.
seltonmt012
force-pushed
the
fix/license-callback-resolution
branch
from
August 8, 2026 18:25
54e9a92 to
ac1e880
Compare
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.
Description
Three server callbacks in
esx_licenseonly answer when they found anxPlayer. When they do not, the client waits forever.Motivation
getLicense,getLicensesandcheckLicenseall callcbinsideif xPlayer then. There is no else. WhenESX.Playerreturns nil the handler simply ends,ESX.TriggerServerCallbackon the client never resolves, and the player gets no menu, no error, and no hint that anything went wrong.It is reachable without doing anything unusual.
esx_boat,esx_weaponshop,esx_vehicleshopandesx_drugsall pass their own server id as the target:That id has no
xPlayeryet during the loading window, and it has none while a character switch is in flight. Walk into the weapon shop at the wrong moment and the shop menu never opens.Implementation Details
Each branch now answers with the same shape its success path uses, so consumers need no new handling:
getLicense{type = ..., label = ...}nilgetLicenses{}checkLicensefalsefalseforcheckLicensekeeps a shop treating an unknown player as unlicensed, which is the branch every consumer already has, rather than leaving it hanging.Driven against the shipped file with
ESX.Playerstubbed to nil:getLicensecb(nil)getLicensescb({})checkLicensecb(false)getLicensesListcb(licenses)getLicensesListnever had the guard and is the control: identical in both runs.Usage Example
PR Checklist
Nothing that answered before answers differently. The three paths that changed previously returned nothing at all.
The plain
AddEventHandlervariants of the same names, further up the file, have the same gap. I left them alone because they are called withTriggerEventfrom server code that passes a known id, so the failure mode there is not the same. Happy to fold them in if you would rather have both consistent.