From fe8184be88b1c5a736b97273574042712324645f Mon Sep 17 00:00:00 2001 From: Sergio <89666307+feelfreetofee@users.noreply.github.com> Date: Fri, 3 Oct 2025 15:53:14 +0200 Subject: [PATCH 1/2] fix(modules/inventory/server.lua): Fix Linter issues Safe Table Navigation from Lua Power Patches does not only breaks the linter, its also broken itself. Avoid using it Signed-off-by: Sergio <89666307+feelfreetofee@users.noreply.github.com> --- modules/inventory/server.lua | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/modules/inventory/server.lua b/modules/inventory/server.lua index 4b046ceed..3e59a937c 100644 --- a/modules/inventory/server.lua +++ b/modules/inventory/server.lua @@ -1116,7 +1116,8 @@ function Inventory.AddItem(inv, item, count, metadata, slot, cb) if not inv?.slots then return false, 'invalid_inventory' end local toSlot, slotMetadata, slotCount - local success, response = false + local success = false + local response metadata = assertMetadata(metadata) @@ -1720,11 +1721,8 @@ lib.callback.register('ox_inventory:swapItems', function(source, data) if fromData.metadata.container and toInventory.type == 'container' then return false end if toData and toData.metadata.container and fromInventory.type == 'container' then return false end - local container, containerItem = (not sameInventory and playerInventory.containerSlot) and (fromInventory.type == 'container' and fromInventory or toInventory) - - if container then - containerItem = playerInventory.items[playerInventory.containerSlot] - end + local container = (not sameInventory and playerInventory.containerSlot) and (fromInventory.type == 'container' and fromInventory or toInventory) + local containerItem = container and playerInventory.items[playerInventory.containerSlot] local hookPayload = { source = source, @@ -1983,7 +1981,7 @@ end) function Inventory.Confiscate(source) local inv = Inventory(source) - if inv?.player then + if inv and inv.player then db.saveStash(inv.owner, inv.owner, json.encode(minimal(inv))) table.wipe(inv.items) inv.weight = 0 @@ -1999,7 +1997,7 @@ exports('ConfiscateInventory', Inventory.Confiscate) function Inventory.Return(source) local inv = Inventory(source) - if not inv?.player then return end + if not inv or not inv.player then return end local items = MySQL.scalar.await('SELECT data FROM ox_inventory WHERE name = ?', { inv.owner }) From 34e5278cd6857adfe3fc80db54abfe423d6389b3 Mon Sep 17 00:00:00 2001 From: Sergio <89666307+feelfreetofee@users.noreply.github.com> Date: Fri, 3 Oct 2025 15:59:24 +0200 Subject: [PATCH 2/2] fix(client.lua): Fix linter issues Signed-off-by: Sergio <89666307+feelfreetofee@users.noreply.github.com> --- client.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client.lua b/client.lua index 413f4a9ea..bece57f4d 100644 --- a/client.lua +++ b/client.lua @@ -422,7 +422,7 @@ end ---@param cb fun(response: SlotWithItem | false)? ---@param noAnim? boolean local function useItem(data, cb, noAnim) - local slotData, result = PlayerData.inventory[data.slot] + local slotData = PlayerData.inventory[data.slot] if not slotData or not canUseItem(data.ammo and true) then if currentWeapon then @@ -442,7 +442,7 @@ local function useItem(data, cb, noAnim) usingItem = true ---@type boolean? - result = lib.callback.await('ox_inventory:useItem', 200, data.name, data.slot, slotData.metadata, noAnim) + local result = lib.callback.await('ox_inventory:useItem', 200, data.name, data.slot, slotData.metadata, noAnim) if result and cb then local success, response = pcall(cb, result and slotData)