Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
14 changes: 6 additions & 8 deletions modules/inventory/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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 })

Expand Down