1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-06-25 03:34:12 +02:00
parent e69f440a3c
commit e5a5cdd799
2 changed files with 20 additions and 15 deletions

View file

@ -1,11 +1,11 @@
local QBCore = exports['qb-core']:GetCoreObject() local QBCore = exports['qb-core']:GetCoreObject()
-- Debug Print Funktion -- Debug Print Function
local function Debug(msg) local function Debug(msg)
print("^2[Shisha Debug] ^7" .. msg) print("^2[Shisha Debug] ^7" .. msg)
end end
-- Überprüfen, ob qb-target verfügbar ist -- Check if qb-target is available
CreateThread(function() CreateThread(function()
Wait(1000) Wait(1000)
Debug("Überprüfe, ob qb-target verfügbar ist...") Debug("Überprüfe, ob qb-target verfügbar ist...")
@ -17,12 +17,12 @@ CreateThread(function()
end end
end) end)
-- Registriere Target für das funktionierende Shisha-Prop -- Register Target for Shisha Props
CreateThread(function() CreateThread(function()
Wait(2000) -- Warte etwas länger, um sicherzustellen, dass alles geladen ist Wait(2000) -- Wait a bit longer to ensure everything is loaded
Debug("Registriere Target für Shisha-Props...") Debug("Registriere Target für Shisha-Props...")
-- Registriere das funktionierende Modell -- Register the working model
local workingModel = "sf_prop_sf_g_bong_01a" local workingModel = "sf_prop_sf_g_bong_01a"
Debug("Registriere Target für funktionierendes Modell: " .. workingModel) Debug("Registriere Target für funktionierendes Modell: " .. workingModel)
@ -40,7 +40,7 @@ CreateThread(function()
Debug("Target für Modell registriert: " .. workingModel) Debug("Target für Modell registriert: " .. workingModel)
-- Versuche auch andere Modelle zu registrieren -- Try to register other models as well
for _, propName in ipairs(Config.ShishaProps) do for _, propName in ipairs(Config.ShishaProps) do
if propName ~= workingModel then if propName ~= workingModel then
Debug("Versuche zusätzliches Modell zu registrieren: " .. propName) Debug("Versuche zusätzliches Modell zu registrieren: " .. propName)
@ -60,13 +60,14 @@ CreateThread(function()
end end
end) end)
-- Event Handler für das Öffnen des Menüs -- Event Handler for opening the menu
RegisterNetEvent('nordi_shisha:client:OpenMenu') RegisterNetEvent('nordi_shisha:client:OpenMenu')
AddEventHandler('nordi_shisha:client:OpenMenu', function() AddEventHandler('nordi_shisha:client:OpenMenu', function()
Debug("Öffne Menü...") Debug("Öffne Menü...")
OpenShishaMenu() OpenShishaMenu()
end) end)
-- Check if player has required ingredients
function CheckIngredients(requirements) function CheckIngredients(requirements)
local hasItems = true local hasItems = true
local missingItems = {} local missingItems = {}
@ -85,6 +86,7 @@ function CheckIngredients(requirements)
return hasItems, missingItems return hasItems, missingItems
end end
-- Show warning for missing ingredients
function ShowMissingIngredientsWarning(missingItems) function ShowMissingIngredientsWarning(missingItems)
local warningText = "Fehlende Zutaten:\n" local warningText = "Fehlende Zutaten:\n"
for _, item in ipairs(missingItems) do for _, item in ipairs(missingItems) do
@ -95,6 +97,7 @@ function ShowMissingIngredientsWarning(missingItems)
QBCore.Functions.Notify(warningText, "error", 5000) QBCore.Functions.Notify(warningText, "error", 5000)
end end
-- Open the shisha menu
function OpenShishaMenu() function OpenShishaMenu()
Debug("Erstelle Menüoptionen...") Debug("Erstelle Menüoptionen...")
local options = {} local options = {}
@ -135,6 +138,7 @@ function OpenShishaMenu()
lib.showContext('shisha_menu') lib.showContext('shisha_menu')
end end
-- Prepare and smoke shisha
function PrepareAndSmokeShisha(selectedShisha) function PrepareAndSmokeShisha(selectedShisha)
Debug("Starte Shisha-Vorbereitung...") Debug("Starte Shisha-Vorbereitung...")
local player = PlayerPedId() local player = PlayerPedId()
@ -155,20 +159,21 @@ function PrepareAndSmokeShisha(selectedShisha)
animDict = animDict, animDict = animDict,
anim = anim, anim = anim,
flags = 49, flags = 49,
}, {}, {}, function() -- Erfolg }, {}, {}, function() -- Success
Debug("Shisha-Vorbereitung erfolgreich, löse Server-Event aus...") Debug("Shisha-Vorbereitung erfolgreich, löse Server-Event aus...")
TriggerServerEvent('shisha-script:consumeTobacco', selectedShisha.requires) TriggerServerEvent('shisha-script:consumeTobacco', selectedShisha.requires)
-- Nach erfolgreicher Vorbereitung direkt rauchen -- Start smoking after successful preparation
SmokeShisha(selectedShisha) SmokeShisha(selectedShisha)
end, function() -- Abgebrochen end, function() -- Cancelled
Debug("Shisha-Vorbereitung abgebrochen") Debug("Shisha-Vorbereitung abgebrochen")
QBCore.Functions.Notify("Vorbereitung abgebrochen", "error") QBCore.Functions.Notify("Vorbereitung abgebrochen", "error")
end) end)
end end
-- Smoke shisha function
function SmokeShisha(selectedShisha) function SmokeShisha(selectedShisha)
local ped = PlayerPedId() local ped = PlayerPedId()
local propName = "v_corp_lngestoolfd" -- Dieses Modell wird aus dem Stream-Ordner geladen local propName = "v_corp_lngestoolfd" -- This model is loaded from the stream folder
local propBone = 28422 local propBone = 28422
local propCoords = vector3(0.0, 0.0, -0.03) local propCoords = vector3(0.0, 0.0, -0.03)
@ -192,18 +197,18 @@ function SmokeShisha(selectedShisha)
TaskPlayAnim(ped, animDict, animName, 8.0, -8.0, -1, 49, 0, false, false, false) TaskPlayAnim(ped, animDict, animName, 8.0, -8.0, -1, 49, 0, false, false, false)
QBCore.Functions.Progressbar("smoke_shisha", selectedShisha.label.." rauchen...", Config.SmokeTime or 10000, false, true, { QBCore.Functions.Progressbar("smoke_shisha", selectedShisha.label.." rauchen...", Config.SmokeTime or 30000, false, true, {
disableMovement = false, disableMovement = false,
disableCarMovement = false, disableCarMovement = false,
disableMouse = false, disableMouse = false,
disableCombat = true, disableCombat = true,
}, {}, {}, {}, function() -- Erfolg }, {}, {}, {}, function() -- Success
ClearPedTasks(ped) ClearPedTasks(ped)
DeleteObject(prop) DeleteObject(prop)
TriggerEvent("evidence:client:SetStatus", "weedsmell", 300) TriggerEvent("evidence:client:SetStatus", "weedsmell", 300)
TriggerServerEvent('hud:server:RelieveStress', math.random(15, 25)) TriggerServerEvent('hud:server:RelieveStress', math.random(15, 25))
QBCore.Functions.Notify("Du fühlst dich entspannt...", "success") QBCore.Functions.Notify("Du fühlst dich entspannt...", "success")
end, function() -- Abgebrochen end, function() -- Cancelled
ClearPedTasks(ped) ClearPedTasks(ped)
DeleteObject(prop) DeleteObject(prop)
end) end)

View file

@ -11,7 +11,7 @@ Config.ShishaProps = {
-- Progressbar Dauer in ms -- Progressbar Dauer in ms
Config.PrepareTime = 5000 Config.PrepareTime = 5000
Config.SmokeTime = 15000 Config.SmokeTime = 30000
-- Verfügbare Shisha-Optionen -- Verfügbare Shisha-Optionen
Config.ShishaOptions = { Config.ShishaOptions = {