I’m not sure if this is related, but I had a similar situation where source would just randomly change on me. Try doing local source = source at the top of the event. That fixed my problem. Not sure if it would help, but worth a try I guess…
AddEventHandler("inventory:add", function(id, item, quantity)
local InvId, InvType = GetInventoryType(id)
local inv
local isAbleToReceive
if InvType == "personal" then
TriggerEvent("es:getPlayerFromId", source, function(user)
inv = user
isAbleToReceive = user.isAbleToReceive(tonumber(item), quantity)
end)
elseif InvType == "car" then
if car == nil or not(car) then
CancelEvent()
end
TriggerEvent("car:getCarFromPlate", InvId, function(car)
inv = car
isAbleToReceive = car.isAbleToReceive(tonumber(item), quantity)
end)
elseif InvType == "chest" then
isAbleToReceive = false -- TODO
end
if isAbleToReceive then
inv.addQuantity(item, quantity) -- à tester sinon IF
TriggerClientEvent("inventory:change", source, json.decode(inv.sendDatas())) -- HERE
end
end)
It’s not mysql. On linux FXServer, if you call a different event/callback, within an event, the souce gets set to nil when the callback is returned. Windows doesn’t seem to be suffering from this. @Briglair is correct, local source = source forces it to persist through. Might not be exactly what OP is running into, but something strange still happening.