Skip to content

Commit

Permalink
feat(bridge/qb/server) assertions for deprecated qb-inventory functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mafewtm committed Jun 5, 2024
1 parent f18df71 commit dce9565
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
5 changes: 2 additions & 3 deletions bridge/qb/server/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ end
---@deprecated No replacement. See https://overextended.dev/ox_inventory/Functions/Client#useitem
---@param source Source
---@param item string name
function functions.UseItem(source, item)
if GetResourceState('qb-inventory') == 'missing' then return end
exports['qb-inventory']:UseItem(source, item)
function functions.UseItem(source, item) -- luacheck: ignore
assert(GetResourceState('qb-inventory') ~= 'started', 'qb-inventory is not compatible with qbx_core. use ox_inventory instead')
end

local discordLink = GetConvar('qbx:discordlink', 'discord.gg/qbox')
Expand Down
25 changes: 10 additions & 15 deletions bridge/qb/server/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,42 +23,37 @@ local playerObj = {}

---@deprecated ox_inventory automatically saves
---@param source Source
function playerObj.SaveInventory(source)
if GetResourceState('qb-inventory') == 'missing' then return end
exports['qb-inventory']:SaveInventory(source, false)
function playerObj.SaveInventory(source) -- luacheck: ignore
assert(GetResourceState('qb-inventory') ~= 'started', 'qb-inventory is not compatible with qbx_core. use ox_inventory instead')
end

---@deprecated ox_inventory automatically saves
---@param playerData PlayerData
function playerObj.SaveOfflineInventory(playerData)
if GetResourceState('qb-inventory') == 'missing' then return end
exports['qb-inventory']:SaveInventory(playerData, true)
function playerObj.SaveOfflineInventory(playerData) -- luacheck: ignore
assert(GetResourceState('qb-inventory') ~= 'started', 'qb-inventory is not compatible with qbx_core. use ox_inventory instead')
end

---@deprecated call ox_inventory exports directly
---@param items any[]
---@return number?
function playerObj.GetTotalWeight(items)
if GetResourceState('qb-inventory') == 'missing' then return end
return exports['qb-inventory']:GetTotalWeight(items)
function playerObj.GetTotalWeight(items) -- luacheck: ignore
assert(GetResourceState('qb-inventory') ~= 'started', 'qb-inventory is not compatible with qbx_core. use ox_inventory instead')
end

---@deprecated call ox_inventory exports directly
---@param items any[]
---@param itemName string
---@return integer[]? slots
function playerObj.GetSlotsByItem(items, itemName)
if GetResourceState('qb-inventory') == 'missing' then return end
return exports['qb-inventory']:GetSlotsByItem(items, itemName)
function playerObj.GetSlotsByItem(items, itemName) -- luacheck: ignore
assert(GetResourceState('qb-inventory') ~= 'started', 'qb-inventory is not compatible with qbx_core. use ox_inventory instead')
end

---@deprecated call ox_inventory exports directly
---@param items any[]
---@param itemName string
---@return integer? slot
function playerObj.GetFirstSlotByItem(items, itemName)
if GetResourceState('qb-inventory') == 'missing' then return end
return exports['qb-inventory']:GetFirstSlotByItem(items, itemName)
function playerObj.GetFirstSlotByItem(items, itemName) -- luacheck: ignore
assert(GetResourceState('qb-inventory') ~= 'started', 'qb-inventory is not compatible with qbx_core. use ox_inventory instead')
end

---@param source Source
Expand Down

0 comments on commit dce9565

Please sign in to comment.