From c22911109a8d3389815a7b71f0c39f05890266b6 Mon Sep 17 00:00:00 2001 From: Nordi98 Date: Wed, 25 Jun 2025 04:24:39 +0200 Subject: [PATCH] Update client.lua --- resources/[inventory]/nordi_hookah/client.lua | 58 ++++++++++++++----- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/resources/[inventory]/nordi_hookah/client.lua b/resources/[inventory]/nordi_hookah/client.lua index 396d93c95..579a97a90 100644 --- a/resources/[inventory]/nordi_hookah/client.lua +++ b/resources/[inventory]/nordi_hookah/client.lua @@ -152,47 +152,77 @@ function PrepareShisha(selectedShisha) Debug("Shisha-Vorbereitung erfolgreich, löse Server-Event aus...") TriggerServerEvent('shisha-script:consumeTobacco', selectedShisha.requires) -- Start smoking after successful preparation - SmokeShisha(selectedShisha) + StartShishaSmoking(selectedShisha) end, function() -- Cancelled Debug("Shisha-Vorbereitung abgebrochen") QBCore.Functions.Notify("Vorbereitung abgebrochen", "error") end) end --- Smoke shisha function with only animation (no prop) -function SmokeShisha(selectedShisha) +-- Smoke shisha function with animation and smoke effect +function StartShishaSmoking(selectedShisha) local ped = PlayerPedId() + local smokeTime = Config.SmokeTime or 30000 + local animDict = "amb@world_human_smoking@male@male_a@enter" + local animName = "enter" + local particleDictionary = "core" + local particleName = "exp_grd_bzgas_smoke" + local animLoopDict = "amb@world_human_smoking@male@male_a@idle_a" + local animLoopName = "idle_a" - -- Rauch-Animation ohne Prop - local animDict = "amb@world_human_aa_smoke@male@idle_a" - local animName = "idle_c" - - -- Request animation + -- Request animation dictionaries RequestAnimDict(animDict) while not HasAnimDictLoaded(animDict) do - Wait(0) + Wait(10) end - -- Play animation - TaskPlayAnim(ped, animDict, animName, 8.0, -8.0, -1, 49, 0, false, false, false) + RequestAnimDict(animLoopDict) + while not HasAnimDictLoaded(animLoopDict) do + Wait(10) + end + + -- Request particle dictionary + RequestNamedPtfxAsset(particleDictionary) + while not HasNamedPtfxAssetLoaded(particleDictionary) do + Wait(10) + end + + -- Start the smoking process + Debug("Starte Rauch-Animation...") + + -- Play initial animation + TaskPlayAnim(ped, animDict, animName, 8.0, -8.0, -1, 0, 0, false, false, false) + Wait(1000) -- Wait for animation to start properly + + -- Switch to loop animation + TaskPlayAnim(ped, animLoopDict, animLoopName, 8.0, -8.0, -1, 1, 0, false, false, false) + + -- Create smoke effect + SetPtfxAssetNextCall(particleDictionary) + local smoke = StartParticleFxLoopedOnEntityBone(particleName, ped, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, GetPedBoneIndex(ped, 20279), 0.1, false, false, false) + SetParticleFxLoopedAlpha(smoke, 0.8) -- Progress bar for smoking - QBCore.Functions.Progressbar("smoke_shisha", selectedShisha.label.." rauchen...", Config.SmokeTime or 30000, false, true, { + QBCore.Functions.Progressbar("smoke_shisha", selectedShisha.label.." rauchen...", smokeTime, false, true, { disableMovement = false, disableCarMovement = false, disableMouse = false, disableCombat = true, }, {}, {}, {}, function() -- Success - -- Clean up animation + -- Clean up animation and smoke effect + StopParticleFxLooped(smoke, 0) ClearPedTasks(ped) - -- Apply effects after smoking is complete + -- NOW apply effects and show message AFTER smoking is complete TriggerEvent("evidence:client:SetStatus", "weedsmell", 300) TriggerServerEvent('hud:server:RelieveStress', math.random(15, 25)) QBCore.Functions.Notify("Du fühlst dich entspannt...", "success") + Debug("Rauchen abgeschlossen, Entspannungseffekte angewendet") end, function() -- Cancelled -- Clean up if cancelled + StopParticleFxLooped(smoke, 0) ClearPedTasks(ped) + Debug("Rauchen abgebrochen") end) end