From 594a3d86f7905bd5493f2a396baca935f00e0150 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Tue, 12 Dec 2023 00:13:27 +1100 Subject: [PATCH] Revert "fix(server): update source for lib.logger (#1537)" This reverts commit 80e5ac8723b720e4619018249baf330916ac3a12. Expecting people to have tested their changes is a good meme. --- modules/inventory/server.lua | 16 ++++++++-------- modules/shops/server.lua | 2 +- server.lua | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/inventory/server.lua b/modules/inventory/server.lua index 53e33259cf..0e44d03b99 100644 --- a/modules/inventory/server.lua +++ b/modules/inventory/server.lua @@ -1113,7 +1113,7 @@ function Inventory.AddItem(inv, item, count, metadata, slot, cb) }, true) if invokingResource then - lib.logger(inv.player.source, 'addItem', ('"%s" added %sx %s to "%s"'):format(invokingResource, count, item.name, inv.label)) + lib.logger(inv.owner, 'addItem', ('"%s" added %sx %s to "%s"'):format(invokingResource, count, item.name, inv.label)) end success = true @@ -1135,7 +1135,7 @@ function Inventory.AddItem(inv, item, count, metadata, slot, cb) inv:syncSlotsWithClients(toSlot, true) if invokingResource then - lib.logger(inv.player.source, 'addItem', ('"%s" added %sx %s to "%s"'):format(invokingResource, added, item.name, inv.label)) + lib.logger(inv.owner, 'addItem', ('"%s" added %sx %s to "%s"'):format(invokingResource, added, item.name, inv.label)) end for i = 1, #toSlot do @@ -1315,7 +1315,7 @@ function Inventory.RemoveItem(inv, item, count, metadata, slot, ignoreTotal) local invokingResource = server.loglevel > 1 and GetInvokingResource() if invokingResource then - lib.logger(inv.player.source, 'removeItem', ('"%s" removed %sx %s from "%s"'):format(invokingResource, removed, item.name, inv.label)) + lib.logger(inv.owner, 'removeItem', ('"%s" removed %sx %s from "%s"'):format(invokingResource, removed, item.name, inv.label)) end return true @@ -1544,7 +1544,7 @@ local function dropItem(source, playerInventory, fromData, data) TriggerClientEvent('ox_inventory:createDrop', -1, dropId, Inventory.Drops[dropId], playerInventory.open and source, slot) if server.loglevel > 0 then - lib.logger(playerInventory.player.source, 'swapSlots', ('%sx %s transferred from "%s" to "%s"'):format(data.count, toData.name, playerInventory.label, dropId)) + lib.logger(playerInventory.owner, 'swapSlots', ('%sx %s transferred from "%s" to "%s"'):format(data.count, toData.name, playerInventory.label, dropId)) end if server.syncInventory then server.syncInventory(playerInventory) end @@ -1697,7 +1697,7 @@ lib.callback.register('ox_inventory:swapItems', function(source, data) toData, fromData = Inventory.SwapSlots(fromInventory, toInventory, data.fromSlot, data.toSlot) --[[@as table]] if server.loglevel > 0 then - lib.logger(playerInventory.player.source, 'swapSlots', ('%sx %s transferred from "%s" to "%s" for %sx %s'):format(fromData.count, fromData.name, fromInventory.owner and fromInventory.label or fromInventory.id, toInventory.owner and toInventory.label or toInventory.id, toData.count, toData.name)) + lib.logger(playerInventory.owner, 'swapSlots', ('%sx %s transferred from "%s" to "%s" for %sx %s'):format(fromData.count, fromData.name, fromInventory.owner and fromInventory.label or fromInventory.id, toInventory.owner and toInventory.label or toInventory.id, toData.count, toData.name)) end else return false, 'cannot_carry' end else @@ -1740,7 +1740,7 @@ lib.callback.register('ox_inventory:swapItems', function(source, data) end if server.loglevel > 0 then - lib.logger(playerInventory.player.source, 'swapSlots', ('%sx %s transferred from "%s" to "%s"'):format(data.count, fromData.name, fromInventory.owner and fromInventory.label or fromInventory.id, toInventory.owner and toInventory.label or toInventory.id)) + lib.logger(playerInventory.owner, 'swapSlots', ('%sx %s transferred from "%s" to "%s"'):format(data.count, fromData.name, fromInventory.owner and fromInventory.label or fromInventory.id, toInventory.owner and toInventory.label or toInventory.id)) end end @@ -1790,7 +1790,7 @@ lib.callback.register('ox_inventory:swapItems', function(source, data) end if server.loglevel > 0 then - lib.logger(playerInventory.player.source, 'swapSlots', ('%sx %s transferred from "%s" to "%s"'):format(data.count, fromData.name, fromInventory.owner and fromInventory.label or fromInventory.id, toInventory.owner and toInventory.label or toInventory.id)) + lib.logger(playerInventory.owner, 'swapSlots', ('%sx %s transferred from "%s" to "%s"'):format(data.count, fromData.name, fromInventory.owner and fromInventory.label or fromInventory.id, toInventory.owner and toInventory.label or toInventory.id)) end end @@ -2393,7 +2393,7 @@ RegisterServerEvent('ox_inventory:giveItem', function(slot, target, count) if Inventory.AddItem(toInventory, item, count, data.metadata, toSlot) then if Inventory.RemoveItem(fromInventory, item, count, data.metadata, slot) then if server.loglevel > 0 then - lib.logger(fromInventory.player.source, 'giveItem', ('"%s" gave %sx %s to "%s"'):format(fromInventory.label, count, data.name, toInventory.label)) + lib.logger(fromInventory.owner, 'giveItem', ('"%s" gave %sx %s to "%s"'):format(fromInventory.label, count, data.name, toInventory.label)) end return diff --git a/modules/shops/server.lua b/modules/shops/server.lua index f2a8407c64..d5cb70693e 100644 --- a/modules/shops/server.lua +++ b/modules/shops/server.lua @@ -271,7 +271,7 @@ lib.callback.register('ox_inventory:buyItem', function(source, data) if server.loglevel > 0 then if server.loglevel > 1 or fromData.price >= 500 then - lib.logger(playerInv.player.source, 'buyItem', ('"%s" %s'):format(playerInv.label, message:lower()), ('shop:%s'):format(shop.label)) + lib.logger(playerInv.owner, 'buyItem', ('"%s" %s'):format(playerInv.label, message:lower()), ('shop:%s'):format(shop.label)) end end diff --git a/server.lua b/server.lua index 49b01b4a99..485f7eb4cd 100644 --- a/server.lua +++ b/server.lua @@ -456,7 +456,7 @@ lib.addCommand({'additem', 'giveitem'}, { source = Inventory(source) or { label = 'console', owner = 'console' } if server.loglevel > 0 then - lib.logger(source.player.source, 'admin', ('"%s" gave %sx %s to "%s"'):format(source.label, count, item.name, inventory.label)) + lib.logger(source.owner, 'admin', ('"%s" gave %sx %s to "%s"'):format(source.label, count, item.name, inventory.label)) end end end) @@ -484,7 +484,7 @@ lib.addCommand('removeitem', { source = Inventory(source) or {label = 'console', owner = 'console'} if server.loglevel > 0 then - lib.logger(source.player.source, 'admin', ('"%s" removed %sx %s from "%s"'):format(source.label, args.count, item.name, inventory.label)) + lib.logger(source.owner, 'admin', ('"%s" removed %sx %s from "%s"'):format(source.label, args.count, item.name, inventory.label)) end end end) @@ -512,7 +512,7 @@ lib.addCommand('setitem', { source = Inventory(source) or {label = 'console', owner = 'console'} if server.loglevel > 0 then - lib.logger(source.player.source, 'admin', ('"%s" set "%s" %s count to %sx'):format(source.label, inventory.label, item.name, args.count)) + lib.logger(source.owner, 'admin', ('"%s" set "%s" %s count to %sx'):format(source.label, inventory.label, item.name, args.count)) end end end)