1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-06-18 05:47:41 +02:00
parent 271588ccb0
commit 0a7362cf0b
2 changed files with 74 additions and 16 deletions

View file

@ -50,15 +50,29 @@ function CheckIngredients(requirements)
local hasItems = true
local missingItems = {}
if not requirements then
Debug("FEHLER: requirements ist nil")
return false, {}
end
for _, requirement in ipairs(requirements) do
local hasItem = QBCore.Functions.HasItem(requirement.item, requirement.amount)
if not requirement or not requirement.item then
Debug("FEHLER: requirement oder requirement.item ist nil")
hasItems = false
goto continue_req
end
local amount = requirement.amount or 1
local hasItem = QBCore.Functions.HasItem(requirement.item, amount)
if not hasItem then
hasItems = false
table.insert(missingItems, {
item = requirement.item,
required = requirement.amount
required = amount
})
end
::continue_req::
end
return hasItems, missingItems
@ -67,6 +81,11 @@ end
function ShowMissingIngredientsWarning(missingItems)
local warningText = "Fehlende Zutaten:\n"
for _, item in ipairs(missingItems) do
if not item or not item.item then
Debug("FEHLER: item oder item.item ist nil")
goto continue_missing
end
local itemLabel = item.item -- Default to item name if label not found
-- Safely check if the item exists in QBCore.Shared.Items
@ -75,6 +94,8 @@ function ShowMissingIngredientsWarning(missingItems)
end
warningText = warningText .. "- " .. itemLabel .. " (benötigt: " .. item.required .. ")\n"
::continue_missing::
end
QBCore.Functions.Notify(warningText, "error", 5000)
@ -94,18 +115,18 @@ function OpenGrillMenu()
for _, food in ipairs(Config.GrillOptions) do
-- Make sure food.requires exists
if not food.requires then
Debug("ERROR: food.requires is nil for " .. (food.label or "unknown food"))
if not food or not food.requires then
Debug("ERROR: food oder food.requires ist nil für " .. (food.label or "unbekanntes Essen"))
goto continue
end
local hasIngredients, missing = CheckIngredients(food.requires)
local description = (food.description or "No description") .. "\n\nBenötigt:"
local description = (food.description or "Keine Beschreibung") .. "\n\nBenötigt:"
for _, req in ipairs(food.requires) do
-- Make sure req.item exists
if not req.item then
Debug("ERROR: req.item is nil")
if not req or not req.item then
Debug("ERROR: req oder req.item ist nil")
goto continue_req
end
@ -113,21 +134,23 @@ function OpenGrillMenu()
local hasItem = false
-- Safely check if the item exists in QBCore.Shared.Items
if QBCore.Shared and QBCore.Shared.Items and QBCore.Shared.Items[req.item] and QBCore.Shared.Items[req.item].label then
itemLabel = QBCore.Shared.Items[req.item].label
hasItem = QBCore.Functions.HasItem(req.item, req.amount)
if QBCore.Shared and QBCore.Shared.Items and QBCore.Shared.Items[req.item] then
if QBCore.Shared.Items[req.item].label then
itemLabel = QBCore.Shared.Items[req.item].label
end
hasItem = QBCore.Functions.HasItem(req.item, req.amount or 1)
else
Debug("Warning: Item " .. req.item .. " not found in QBCore.Shared.Items")
Debug("Warnung: Item " .. req.item .. " nicht in QBCore.Shared.Items gefunden")
end
local status = hasItem and "~g~✓" or "~r~✗"
description = description .. "\n- " .. req.amount .. "x " .. itemLabel .. " " .. status
description = description .. "\n- " .. (req.amount or 1) .. "x " .. itemLabel .. " " .. status
::continue_req::
end
table.insert(options, {
title = food.label or "Unknown Food",
title = food.label or "Unbekanntes Essen",
description = description,
icon = food.icon or "fas fa-question",
onSelect = function()
@ -200,3 +223,4 @@ AddEventHandler('grill-script:debug', function(msg)
Debug(msg)
end)

View file

@ -1,5 +1,40 @@
Config = {}
-- Validate that the items exist in QBCore.Shared.Items
CreateThread(function()
Wait(2000) -- Wait for QBCore to be fully initialized
local QBCore = exports['qb-core']:GetCoreObject()
if not QBCore or not QBCore.Shared or not QBCore.Shared.Items then
print("^1ERROR: QBCore.Shared.Items is not available^7")
return
end
-- Check if all required items exist
local missingItems = {}
for _, option in ipairs(Config.GrillOptions) do
if not QBCore.Shared.Items[option.item] then
table.insert(missingItems, option.item)
end
for _, req in ipairs(option.requires) do
if not QBCore.Shared.Items[req.item] then
table.insert(missingItems, req.item)
end
end
end
if #missingItems > 0 then
print("^1WARNING: The following items are missing from QBCore.Shared.Items:^7")
for _, item in ipairs(missingItems) do
print("^1- " .. item .. "^7")
end
else
print("^2All grill items exist in QBCore.Shared.Items^7")
end
end)
-- Change coffee props to grill props
Config.GrillProps = {
`prop_bbq_1`,
@ -12,12 +47,10 @@ Config.GrillProps = {
`bzzz_grill_a`,
`smallbbqtrailer`,
`bigbbqtrailer`,
-- Add any other grill props you want to use
}
-- Progressbar duration in ms
Config.ProgressTime = 5000 -- Maybe increase time for grilling
Config.ProgressTime = 5000
-- Change coffee options to grilling options
Config.GrillOptions = {
@ -40,3 +73,4 @@ Config.GrillOptions = {
}
},
}