From 172bad1c0fa213e8291df38c37e678e16ed02645 Mon Sep 17 00:00:00 2001 From: Zerio Date: Mon, 2 Jun 2025 08:17:25 +0200 Subject: [PATCH 1/2] feat: update `UseItem` function --- server/main.lua | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/server/main.lua b/server/main.lua index 2bb9408..dc75f92 100644 --- a/server/main.lua +++ b/server/main.lua @@ -451,14 +451,10 @@ exports("GetUsableItem", GetUsableItem) ---@param itemName string The name of the item to use ---@param ... any Arguments for the callback, this will be sent to the callback and can be used to get certain values local function UseItem(itemName, ...) - local itemData = GetUsableItem(itemName) - if type(itemData) ~= "table" then - return false + local itemData = QBCore.Functions.CanUseItem(itemName) + if type(itemData) == 'table' and itemData.func then + itemData.func(...) end - if not itemData.func then - return false - end - itemData.func(...) end exports("UseItem", UseItem) From 9c7e61bfae4ba5e02421355e2d471fdaf5bdd1f2 Mon Sep 17 00:00:00 2001 From: Zerio Date: Mon, 2 Jun 2025 08:19:29 +0200 Subject: [PATCH 2/2] chore: remove code duplication --- server/main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/main.lua b/server/main.lua index dc75f92..461c66f 100644 --- a/server/main.lua +++ b/server/main.lua @@ -451,7 +451,7 @@ exports("GetUsableItem", GetUsableItem) ---@param itemName string The name of the item to use ---@param ... any Arguments for the callback, this will be sent to the callback and can be used to get certain values local function UseItem(itemName, ...) - local itemData = QBCore.Functions.CanUseItem(itemName) + local itemData = GetUsableItem(itemName) if type(itemData) == 'table' and itemData.func then itemData.func(...) end