Skip to content

Commit

Permalink
fix(server): update source for lib.logger (#1537)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaanhehe authored Dec 10, 2023
1 parent f798676 commit 80e5ac8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions modules/inventory/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ function Inventory.AddItem(inv, item, count, metadata, slot, cb)
}, true)

if invokingResource then
lib.logger(inv.owner, 'addItem', ('"%s" added %sx %s to "%s"'):format(invokingResource, count, item.name, inv.label))
lib.logger(inv.player.source, 'addItem', ('"%s" added %sx %s to "%s"'):format(invokingResource, count, item.name, inv.label))
end

success = true
Expand All @@ -1135,7 +1135,7 @@ function Inventory.AddItem(inv, item, count, metadata, slot, cb)
inv:syncSlotsWithClients(toSlot, true)

if invokingResource then
lib.logger(inv.owner, 'addItem', ('"%s" added %sx %s to "%s"'):format(invokingResource, added, item.name, inv.label))
lib.logger(inv.player.source, 'addItem', ('"%s" added %sx %s to "%s"'):format(invokingResource, added, item.name, inv.label))
end

for i = 1, #toSlot do
Expand Down Expand Up @@ -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.owner, 'removeItem', ('"%s" removed %sx %s from "%s"'):format(invokingResource, removed, item.name, inv.label))
lib.logger(inv.player.source, 'removeItem', ('"%s" removed %sx %s from "%s"'):format(invokingResource, removed, item.name, inv.label))
end

return true
Expand Down Expand Up @@ -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.owner, 'swapSlots', ('%sx %s transferred from "%s" to "%s"'):format(data.count, toData.name, playerInventory.label, dropId))
lib.logger(playerInventory.player.source, '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
Expand Down Expand Up @@ -1694,7 +1694,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.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))
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))
end
else return false, 'cannot_carry' end
else
Expand Down Expand Up @@ -1737,7 +1737,7 @@ lib.callback.register('ox_inventory:swapItems', function(source, data)
end

if server.loglevel > 0 then
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))
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))
end
end

Expand Down Expand Up @@ -1787,7 +1787,7 @@ lib.callback.register('ox_inventory:swapItems', function(source, data)
end

if server.loglevel > 0 then
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))
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))
end
end

Expand Down Expand Up @@ -2388,7 +2388,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.owner, 'giveItem', ('"%s" gave %sx %s to "%s"'):format(fromInventory.label, count, data.name, toInventory.label))
lib.logger(fromInventory.player.source, 'giveItem', ('"%s" gave %sx %s to "%s"'):format(fromInventory.label, count, data.name, toInventory.label))
end

return
Expand Down
2 changes: 1 addition & 1 deletion modules/shops/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.owner, 'buyItem', ('"%s" %s'):format(playerInv.label, message:lower()), ('shop:%s'):format(shop.label))
lib.logger(playerInv.player.source, 'buyItem', ('"%s" %s'):format(playerInv.label, message:lower()), ('shop:%s'):format(shop.label))
end
end

Expand Down
6 changes: 3 additions & 3 deletions server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ lib.addCommand({'additem', 'giveitem'}, {
source = Inventory(source) or { label = 'console', owner = 'console' }

if server.loglevel > 0 then
lib.logger(source.owner, 'admin', ('"%s" gave %sx %s to "%s"'):format(source.label, count, item.name, inventory.label))
lib.logger(source.player.source, 'admin', ('"%s" gave %sx %s to "%s"'):format(source.label, count, item.name, inventory.label))
end
end
end)
Expand Down Expand Up @@ -484,7 +484,7 @@ lib.addCommand('removeitem', {
source = Inventory(source) or {label = 'console', owner = 'console'}

if server.loglevel > 0 then
lib.logger(source.owner, 'admin', ('"%s" removed %sx %s from "%s"'):format(source.label, args.count, item.name, inventory.label))
lib.logger(source.player.source, 'admin', ('"%s" removed %sx %s from "%s"'):format(source.label, args.count, item.name, inventory.label))
end
end
end)
Expand Down Expand Up @@ -512,7 +512,7 @@ lib.addCommand('setitem', {
source = Inventory(source) or {label = 'console', owner = 'console'}

if server.loglevel > 0 then
lib.logger(source.owner, 'admin', ('"%s" set "%s" %s count to %sx'):format(source.label, inventory.label, item.name, args.count))
lib.logger(source.player.source, 'admin', ('"%s" set "%s" %s count to %sx'):format(source.label, inventory.label, item.name, args.count))
end
end
end)
Expand Down

0 comments on commit 80e5ac8

Please sign in to comment.