fix(esx_drugs): track the processing bounds per player - #135
Open
seltonmt012 wants to merge 1 commit into
Open
Conversation
outofbound was a single upvalue shared by everyone. esx_drugs:outofbound is a net event with no source of its own, so the first player who walked out of the weed lab ended the processing loop of every other player in it. Starting to process reset the same flag for everyone as well, so one player entering the lab cleared another player's out of bounds state. Keyed the flag by source, and cleared the entry in CancelProcessing so it does not outlive the session. Clearing it also ends the loop of a player who dropped. Before, playerDropped only removed the timeout id, and the loop was still spinning, so on its next pass it found no id and armed a fresh timeout against the stale xPlayer of a player who had already left. Two players processing with enough cannabis that neither runs out, driven against the shipped handler on a fake scheduler: nobody leaves 2 of 2 loops alive, unchanged by this commit player 2 leaves field before 2 -> 0, after 2 -> 1 player 2 disconnects before 2 -> 2, after 2 -> 1
seltonmt012
force-pushed
the
fix/drugs-per-player-bounds
branch
from
August 8, 2026 18:25
059bb20 to
f757944
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
outofboundis one variable shared by every player, so one person leaving the weed lab stops everyone else's processing.Motivation
esx_drugs:outofboundis a net event, and its handler writes that single upvalue without looking atsource. The processing loop reads the same one:So the first player who steps out of the lab ends the loop of every other player standing in it. Their cannabis stops turning into marijuana with no message and no way to tell why. Starting to process has the mirror problem: it sets the shared flag back to
false, so one player walking in clears another player's out of bounds state.There is a second effect on the same variable.
esx:playerDroppedcallsCancelProcessing, which only removes the timeout id. The loop is still spinning, so on its next pass it finds no id and arms a fresh timeout against thexPlayerof somebody who already left the server.Implementation Details
The flag is keyed by source, and
CancelProcessingclears the entry so it does not outlive the session.Clearing it also ends the loop of a dropped player, because the loop condition no longer holds. That falls out of the same change rather than being a separate mechanism.
Two players processing, both carrying enough cannabis that neither runs out, driven against the shipped handler on a fake scheduler:
The control run is unchanged, which is what says the difference comes from the flag and not from the loop ending for some other reason.
Usage Example
PR Checklist
Scope note, so it is not a surprise later: the cancel path in this handler has problems this PR does not touch.
esx_drugs:cancelProcessingis fired withTriggerEventfrom inside the timeout, wheresourceis not the player it means, and the loop re-arms a timeout whenever the map entry is gone. I kept this change to the shared flag because that is the part with cross player damage. Tell me if you want the rest folded in here instead of a follow up.Tested headless against the shipped file, not with two clients on a live server.