diff --git a/resources/[inventory]/nordi_bbq/client.lua b/resources/[inventory]/nordi_bbq/client.lua index d54acae40..6775f78fd 100644 --- a/resources/[inventory]/nordi_bbq/client.lua +++ b/resources/[inventory]/nordi_bbq/client.lua @@ -49,29 +49,44 @@ function CheckIngredients(requirements) return hasItems, missingItems end + function ShowMissingIngredientsWarning(missingItems) local warningText = "Fehlende Zutaten:\n" for _, item in ipairs(missingItems) do - local itemLabel = QBCore.Shared.Items[item.item].label - warningText = warningText .. "- " .. itemLabel .. " (benötigt: " .. item.required .. ")\n" + -- Add a check to make sure the item exists in QBCore.Shared.Items + if QBCore.Shared.Items[item.item] then + local itemLabel = QBCore.Shared.Items[item.item].label + warningText = warningText .. "- " .. itemLabel .. " (benötigt: " .. item.required .. ")\n" + else + -- Use the item name if the item doesn't exist in QBCore.Shared.Items + warningText = warningText .. "- " .. item.item .. " (benötigt: " .. item.required .. ")\n" + end end QBCore.Functions.Notify(warningText, "error", 5000) end -function OpenGrillMenu() -- Changed function name + +function OpenGrillMenu() Debug("Building menu options...") local options = {} - for _, food in ipairs(Config.GrillOptions) do -- Changed from CoffeeOptions to GrillOptions + for _, food in ipairs(Config.GrillOptions) do local hasIngredients, missing = CheckIngredients(food.requires) local description = food.description .. "\n\nBenötigt:" for _, req in ipairs(food.requires) do - local itemLabel = QBCore.Shared.Items[req.item].label - local hasItem = QBCore.Functions.HasItem(req.item, req.amount) - local status = hasItem and "~g~✓" or "~r~✗" - description = description .. "\n- " .. req.amount .. "x " .. itemLabel .. " " .. status + -- Add a check to make sure the item exists in QBCore.Shared.Items + if QBCore.Shared.Items[req.item] then + local itemLabel = QBCore.Shared.Items[req.item].label + local hasItem = QBCore.Functions.HasItem(req.item, req.amount) + local status = hasItem and "~g~✓" or "~r~✗" + description = description .. "\n- " .. req.amount .. "x " .. itemLabel .. " " .. status + else + -- Handle the case where the item doesn't exist + Debug("Warning: Item " .. req.item .. " not found in QBCore.Shared.Items") + description = description .. "\n- " .. req.amount .. "x " .. req.item .. " (Item not found)" + end end table.insert(options, { @@ -81,7 +96,7 @@ function OpenGrillMenu() -- Changed function name onSelect = function() local canMake, missingItems = CheckIngredients(food.requires) if canMake then - PrepareFood(food) -- Changed function name + PrepareFood(food) else ShowMissingIngredientsWarning(missingItems) end @@ -91,12 +106,12 @@ function OpenGrillMenu() -- Changed function name Debug("Showing menu...") lib.registerContext({ - id = 'grill_menu', -- Changed ID - title = 'Grill', -- Changed title + id = 'grill_menu', + title = 'Grill', options = options }) - lib.showContext('grill_menu') -- Changed context ID + lib.showContext('grill_menu') end function PrepareFood(selectedFood) -- Changed function name diff --git a/resources/[inventory]/nordi_bbq/config.lua b/resources/[inventory]/nordi_bbq/config.lua index 1f7c999ba..45adb1a2e 100644 --- a/resources/[inventory]/nordi_bbq/config.lua +++ b/resources/[inventory]/nordi_bbq/config.lua @@ -36,7 +36,7 @@ Config.GrillOptions = { item = "cooked_bbq_sausages", icon = "fa-solid fa-hotdog", requires = { - {item = "raw_sausage", amount = 1}, + {item = "raw_sausages", amount = 1}, } }, }