1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-06-18 05:33:48 +02:00
parent 0cc6ba6923
commit 349f167025
2 changed files with 28 additions and 13 deletions

View file

@ -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
-- 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
-- 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

View file

@ -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},
}
},
}