forked from Simnation/Main
nordi bbq
This commit is contained in:
parent
910266a2f4
commit
e263643095
4 changed files with 291 additions and 0 deletions
135
resources/[inventory]/nordi_bbq/client.lua
Normal file
135
resources/[inventory]/nordi_bbq/client.lua
Normal file
|
@ -0,0 +1,135 @@
|
||||||
|
local QBCore = exports['qb-core']:GetCoreObject()
|
||||||
|
|
||||||
|
-- Debug Print Function
|
||||||
|
local function Debug(msg)
|
||||||
|
print("^2[Grill Debug] ^7" .. msg) -- Changed from Coffee to Grill
|
||||||
|
end
|
||||||
|
|
||||||
|
CreateThread(function()
|
||||||
|
Debug("Script starting...")
|
||||||
|
for _, prop in pairs(Config.GrillProps) do -- Changed from CoffeeProps to GrillProps
|
||||||
|
exports['qb-target']:AddTargetModel(prop, {
|
||||||
|
options = {
|
||||||
|
{
|
||||||
|
num = 1,
|
||||||
|
type = "client",
|
||||||
|
event = "nordi_grill:client:OpenMenu", -- Changed event name
|
||||||
|
icon = 'fas fa-fire', -- Changed icon
|
||||||
|
label = 'Grillen', -- Changed label
|
||||||
|
}
|
||||||
|
},
|
||||||
|
distance = 2.0
|
||||||
|
})
|
||||||
|
end
|
||||||
|
Debug("Target options registered")
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- Event Handler for opening the menu
|
||||||
|
RegisterNetEvent('nordi_grill:client:OpenMenu') -- Changed event name
|
||||||
|
AddEventHandler('nordi_grill:client:OpenMenu', function() -- Changed event name
|
||||||
|
Debug("Opening menu...")
|
||||||
|
OpenGrillMenu() -- Changed function name
|
||||||
|
end)
|
||||||
|
|
||||||
|
function CheckIngredients(requirements)
|
||||||
|
local hasItems = true
|
||||||
|
local missingItems = {}
|
||||||
|
|
||||||
|
for _, requirement in ipairs(requirements) do
|
||||||
|
local hasItem = QBCore.Functions.HasItem(requirement.item, requirement.amount)
|
||||||
|
if not hasItem then
|
||||||
|
hasItems = false
|
||||||
|
table.insert(missingItems, {
|
||||||
|
item = requirement.item,
|
||||||
|
required = requirement.amount
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
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"
|
||||||
|
end
|
||||||
|
|
||||||
|
QBCore.Functions.Notify(warningText, "error", 5000)
|
||||||
|
end
|
||||||
|
|
||||||
|
function OpenGrillMenu() -- Changed function name
|
||||||
|
Debug("Building menu options...")
|
||||||
|
local options = {}
|
||||||
|
|
||||||
|
for _, food in ipairs(Config.GrillOptions) do -- Changed from CoffeeOptions to GrillOptions
|
||||||
|
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
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(options, {
|
||||||
|
title = food.label,
|
||||||
|
description = description,
|
||||||
|
icon = food.icon,
|
||||||
|
onSelect = function()
|
||||||
|
local canMake, missingItems = CheckIngredients(food.requires)
|
||||||
|
if canMake then
|
||||||
|
PrepareFood(food) -- Changed function name
|
||||||
|
else
|
||||||
|
ShowMissingIngredientsWarning(missingItems)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
Debug("Showing menu...")
|
||||||
|
lib.registerContext({
|
||||||
|
id = 'grill_menu', -- Changed ID
|
||||||
|
title = 'Grill', -- Changed title
|
||||||
|
options = options
|
||||||
|
})
|
||||||
|
|
||||||
|
lib.showContext('grill_menu') -- Changed context ID
|
||||||
|
end
|
||||||
|
|
||||||
|
function PrepareFood(selectedFood) -- Changed function name
|
||||||
|
Debug("Starting food preparation...")
|
||||||
|
local player = PlayerPedId()
|
||||||
|
local animDict = "amb@prop_human_bbq@male@base" -- Changed animation
|
||||||
|
local anim = "base" -- Changed animation
|
||||||
|
|
||||||
|
RequestAnimDict(animDict)
|
||||||
|
while not HasAnimDictLoaded(animDict) do
|
||||||
|
Wait(0)
|
||||||
|
end
|
||||||
|
|
||||||
|
QBCore.Functions.Progressbar("grill_food", selectedFood.label.." wird gegrillt...", Config.ProgressTime or 5000, false, true, { -- Changed text and function name
|
||||||
|
disableMovement = true,
|
||||||
|
disableCarMovement = true,
|
||||||
|
disableMouse = false,
|
||||||
|
disableCombat = true,
|
||||||
|
}, {
|
||||||
|
animDict = animDict,
|
||||||
|
anim = anim,
|
||||||
|
flags = 49,
|
||||||
|
}, {}, {}, function() -- Success
|
||||||
|
Debug("Food preparation successful, triggering server event...")
|
||||||
|
TriggerServerEvent('grill-script:giveFood', selectedFood.item, selectedFood.requires) -- Changed event name
|
||||||
|
end, function() -- Cancelled
|
||||||
|
Debug("Food preparation cancelled")
|
||||||
|
QBCore.Functions.Notify("Zubereitung abgebrochen", "error")
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Debug Event
|
||||||
|
RegisterNetEvent('grill-script:debug') -- Changed event name
|
||||||
|
AddEventHandler('grill-script:debug', function(msg)
|
||||||
|
Debug(msg)
|
||||||
|
end)
|
72
resources/[inventory]/nordi_bbq/config.lua
Normal file
72
resources/[inventory]/nordi_bbq/config.lua
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
Config = {}
|
||||||
|
|
||||||
|
-- Change coffee props to grill props
|
||||||
|
Config.GrillProps = {
|
||||||
|
`prop_bbq_1`,
|
||||||
|
`prop_bbq_2`,
|
||||||
|
`prop_bbq_3`,
|
||||||
|
`prop_bbq_4`,
|
||||||
|
`prop_bbq_5`,
|
||||||
|
`bzzz_grill_small_a`,
|
||||||
|
`bzzz_grill_small_b`,
|
||||||
|
`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
|
||||||
|
|
||||||
|
-- Change coffee options to grilling options
|
||||||
|
Config.GrillOptions = {
|
||||||
|
{
|
||||||
|
label = "Hamburger",
|
||||||
|
description = "Ein saftiger Hamburger",
|
||||||
|
item = "hamburger",
|
||||||
|
icon = "fa-solid fa-burger",
|
||||||
|
requires = {
|
||||||
|
{item = "raw_beef", amount = 1},
|
||||||
|
{item = "burger_bun", amount = 1},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label = "Cheeseburger",
|
||||||
|
description = "Ein Hamburger mit Käse",
|
||||||
|
item = "cheeseburger",
|
||||||
|
icon = "fa-solid fa-burger",
|
||||||
|
requires = {
|
||||||
|
{item = "raw_beef", amount = 1},
|
||||||
|
{item = "burger_bun", amount = 1},
|
||||||
|
{item = "cheese", amount = 1}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label = "Steak",
|
||||||
|
description = "Ein perfekt gegrilltes Steak",
|
||||||
|
item = "steak",
|
||||||
|
icon = "fa-solid fa-drumstick-bite",
|
||||||
|
requires = {
|
||||||
|
{item = "ribeye_steak", amount = 1},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label = "Bratwurst",
|
||||||
|
description = "Eine leckere Bratwurst",
|
||||||
|
item = "grilled_sausage",
|
||||||
|
icon = "fa-solid fa-hotdog",
|
||||||
|
requires = {
|
||||||
|
{item = "raw_sausage", amount = 1},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label = "Gegrilltes Gemüse",
|
||||||
|
description = "Grillgemüse – weil Salat keine Röstaromen hat",
|
||||||
|
item = "grilled_vegetables",
|
||||||
|
icon = "fa-solid fa-carrot",
|
||||||
|
requires = {
|
||||||
|
{item = "vegetables", amount = 1},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
28
resources/[inventory]/nordi_bbq/fxmanifest.lua
Normal file
28
resources/[inventory]/nordi_bbq/fxmanifest.lua
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
|
||||||
|
fx_version 'cerulean'
|
||||||
|
game 'gta5'
|
||||||
|
|
||||||
|
description 'Kaffee mit qb_target'
|
||||||
|
author 'Nordi'
|
||||||
|
version '1.0.0'
|
||||||
|
|
||||||
|
shared_scripts {
|
||||||
|
'@ox_lib/init.lua',
|
||||||
|
'config.lua'
|
||||||
|
}
|
||||||
|
|
||||||
|
client_scripts {
|
||||||
|
'client.lua'
|
||||||
|
}
|
||||||
|
|
||||||
|
server_scripts {
|
||||||
|
'server.lua'
|
||||||
|
}
|
||||||
|
|
||||||
|
lua54 'yes'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
'qb-target',
|
||||||
|
'qb-core',
|
||||||
|
'ox_lib'
|
||||||
|
}
|
56
resources/[inventory]/nordi_bbq/server.lua
Normal file
56
resources/[inventory]/nordi_bbq/server.lua
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
local QBCore = exports['qb-core']:GetCoreObject()
|
||||||
|
|
||||||
|
-- Debug Print Function
|
||||||
|
local function Debug(msg)
|
||||||
|
print("^2[Grill Debug] ^7" .. msg) -- Changed from Coffee to Grill
|
||||||
|
end
|
||||||
|
|
||||||
|
RegisterNetEvent('grill-script:giveFood') -- Changed event name
|
||||||
|
AddEventHandler('grill-script:giveFood', function(itemName, requirements) -- Changed event name
|
||||||
|
Debug("Give food event triggered") -- Changed text
|
||||||
|
local src = source
|
||||||
|
local Player = QBCore.Functions.GetPlayer(src)
|
||||||
|
|
||||||
|
if Player then
|
||||||
|
-- Check if the item is in the allowed grill options
|
||||||
|
local isValidItem = false
|
||||||
|
for _, food in ipairs(Config.GrillOptions) do -- Changed from CoffeeOptions to GrillOptions
|
||||||
|
if food.item == itemName then
|
||||||
|
isValidItem = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if isValidItem then
|
||||||
|
Debug("Valid food item requested") -- Changed text
|
||||||
|
-- Double-check ingredients
|
||||||
|
local hasAllItems = true
|
||||||
|
for _, requirement in ipairs(requirements) do
|
||||||
|
if not Player.Functions.HasItem(requirement.item, requirement.amount) then
|
||||||
|
hasAllItems = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if hasAllItems then
|
||||||
|
Debug("Player has all required items")
|
||||||
|
-- Remove required items
|
||||||
|
for _, requirement in ipairs(requirements) do
|
||||||
|
Player.Functions.RemoveItem(requirement.item, requirement.amount)
|
||||||
|
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[requirement.item], "remove")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Give the finished food
|
||||||
|
Player.Functions.AddItem(itemName, 1)
|
||||||
|
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[itemName], "add")
|
||||||
|
TriggerClientEvent('QBCore:Notify', src, "Du hast " .. QBCore.Shared.Items[itemName].label .. " gegrillt!", "success") -- Changed text
|
||||||
|
else
|
||||||
|
Debug("Player missing required items")
|
||||||
|
TriggerClientEvent('QBCore:Notify', src, "Du hast nicht alle benötigten Zutaten!", "error")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Debug("Invalid food item requested: " .. itemName) -- Changed text
|
||||||
|
TriggerClientEvent('QBCore:Notify', src, "Fehler beim Grillen!", "error") -- Changed text
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
Loading…
Add table
Add a link
Reference in a new issue