From f7579444f12f5012da1342a7a0f2acfcb82852b4 Mon Sep 17 00:00:00 2001 From: Selt <83926739+seltonmt012@users.noreply.github.com> Date: Sat, 8 Aug 2026 18:53:23 +0200 Subject: [PATCH] fix(esx_drugs): track the processing bounds per player 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 --- [esx_addons]/esx_drugs/server/main.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/[esx_addons]/esx_drugs/server/main.lua b/[esx_addons]/esx_drugs/server/main.lua index cbb24605..962300cf 100644 --- a/[esx_addons]/esx_drugs/server/main.lua +++ b/[esx_addons]/esx_drugs/server/main.lua @@ -1,5 +1,5 @@ local playersProcessingCannabis = {} -local outofbound = true +local outofbound = {} local alive = true local function ValidatePickupCannabis(src) @@ -101,7 +101,7 @@ end) RegisterServerEvent('esx_drugs:outofbound') AddEventHandler('esx_drugs:outofbound', function() - outofbound = true + outofbound[source] = true end) ESX.RegisterServerCallback('esx_drugs:cannabis_count', function(source, cb) @@ -118,9 +118,9 @@ AddEventHandler('esx_drugs:processCannabis', function() local xPlayer = ESX.Player(source) local xCannabis = xPlayer.getInventoryItem('cannabis') local can = true - outofbound = false + outofbound[source] = false if xCannabis.count >= 3 then - while outofbound == false and can do + while outofbound[source] == false and can do if playersProcessingCannabis[source] == nil then playersProcessingCannabis[source] = ESX.SetTimeout(Config.Delays.WeedProcessing , function() if xCannabis.count >= 3 then @@ -157,6 +157,8 @@ AddEventHandler('esx_drugs:processCannabis', function() end) function CancelProcessing(playerId) + outofbound[playerId] = nil + if playersProcessingCannabis[playerId] then ESX.ClearTimeout(playersProcessingCannabis[playerId]) playersProcessingCannabis[playerId] = nil