local QBCore = exports['qb-core']:GetCoreObject() local fireworkTime = 0 local fireworkLoc = nil local fireworkList = { ['proj_xmas_firework'] = { 'scr_firework_xmas_ring_burst_rgw', 'scr_firework_xmas_burst_rgw', 'scr_firework_xmas_repeat_burst_rgw', 'scr_firework_xmas_spiral_burst_rgw', 'scr_xmas_firework_sparkle_spawn' }, ['scr_indep_fireworks'] = { 'scr_indep_firework_sparkle_spawn', 'scr_indep_firework_starburst', 'scr_indep_firework_shotburst', 'scr_indep_firework_trailburst', 'scr_indep_firework_trailburst_spawn', 'scr_indep_firework_burst_spawn', 'scr_indep_firework_trail_spawn', 'scr_indep_firework_fountain' }, ['proj_indep_firework'] = { 'scr_indep_firework_grd_burst', 'scr_indep_launcher_sparkle_spawn', 'scr_indep_firework_air_burst', 'proj_indep_flare_trail' }, ['proj_indep_firework_v2'] = { 'scr_firework_indep_burst_rwb', 'scr_firework_indep_spiral_burst_rwb', 'scr_xmas_firework_sparkle_spawn', 'scr_firework_indep_ring_burst_rwb', 'scr_xmas_firework_burst_fizzle', 'scr_firework_indep_repeat_burst_rwb' } } local function DrawText3D(x, y, z, text) SetTextScale(0.35, 0.35) SetTextFont(4) SetTextProportional(true) SetTextColour(255, 255, 255, 215) BeginTextCommandDisplayText('STRING') SetTextCentre(true) AddTextComponentSubstringPlayerName(text) SetDrawOrigin(x, y, z, 0) EndTextCommandDisplayText(0.0, 0.0) local factor = (string.len(text)) / 370 DrawRect(0.0, 0.0 + 0.0125, 0.017 + factor, 0.03, 0, 0, 0, 75) ClearDrawOrigin() end local function fireworkText() CreateThread(function() while true do Wait(0) if fireworkTime > 0 and fireworkLoc then DrawText3D(fireworkLoc.x, fireworkLoc.y, fireworkLoc.z, Lang:t('firework.time_left') .. fireworkTime) end if fireworkTime <= 0 then break end end end) end -- Verbesserte Feuerwerk-Funktion local function startFirework(asset, coords) fireworkTime = Config.Fireworks.delay fireworkLoc = { x = coords.x, y = coords.y, z = coords.z } -- Stelle sicher, dass das Asset geladen ist if not HasNamedPtfxAssetLoaded(asset) then RequestNamedPtfxAsset(asset) local timeout = 0 while not HasNamedPtfxAssetLoaded(asset) and timeout < 100 do Wait(10) timeout = timeout + 1 end if timeout >= 100 then print("Fehler: Asset konnte nicht geladen werden: " .. asset) return end end CreateThread(function() fireworkText() while fireworkTime > 0 do Wait(1000) fireworkTime = fireworkTime - 1 end print("Countdown beendet, starte Feuerwerk mit Asset: " .. asset) -- Verschiedene Höhen für verschiedene Effekte local heights = {15.0, 20.0, 25.0, 30.0} for i = 1, math.random(5, 10), 1 do local firework = fireworkList[asset][math.random(1, #fireworkList[asset])] local height = heights[math.random(1, #heights)] print("Starte Feuerwerk-Effekt: " .. firework .. " auf Höhe: " .. height) -- Stelle sicher, dass das Asset für jeden Effekt aktiviert wird UseParticleFxAssetNextCall(asset) -- Erhöhte Skalierung für bessere Sichtbarkeit local scale = math.random() * 0.8 + 1.2 -- Zwischen 1.2 und 2.0 -- Starte den Effekt local success = StartParticleFxNonLoopedAtCoord( firework, fireworkLoc.x, fireworkLoc.y, fireworkLoc.z + height, 0.0, 0.0, 0.0, scale, false, false, false ) if success then print("Effekt erfolgreich gestartet") else print("Fehler beim Starten des Effekts") end -- Füge einen Soundeffekt hinzu PlaySoundFromCoord(-1, "firework_burst_01", fireworkLoc.x, fireworkLoc.y, fireworkLoc.z, "dlc_sum20_beach_party_sounds", true, 20.0, false) -- Variiere die Wartezeit zwischen den Effekten Wait(math.random(200, 800)) end fireworkLoc = nil end) end -- Lade alle Assets beim Start CreateThread(function() local assets = { 'scr_indep_fireworks', 'proj_xmas_firework', 'proj_indep_firework_v2', 'proj_indep_firework' } for i = 1, #assets do local asset = assets[i] print("Lade Asset: " .. asset) RequestNamedPtfxAsset(asset) local timeout = 0 while not HasNamedPtfxAssetLoaded(asset) and timeout < 500 do Wait(10) timeout = timeout + 1 end if HasNamedPtfxAssetLoaded(asset) then print("Asset erfolgreich geladen: " .. asset) else print("Fehler beim Laden des Assets: " .. asset) end end print("Alle Feuerwerk-Assets geladen") end) RegisterNetEvent('fireworks:client:UseFirework', function(itemName, assetName) print("Feuerwerk-Event ausgelöst mit Item: " .. itemName .. " und Asset: " .. assetName) QBCore.Functions.Progressbar('spawn_object', Lang:t('firework.place_progress'), 3000, false, true, { disableMovement = true, disableCarMovement = true, disableMouse = false, disableCombat = true, }, { animDict = 'anim@narcotics@trash', anim = 'drop_front', flags = 16, }, {}, {}, function() -- Done StopAnimTask(PlayerPedId(), 'anim@narcotics@trash', 'drop_front', 1.0) TriggerServerEvent('consumables:server:UseFirework', itemName) TriggerEvent('qb-inventory:client:ItemBox', QBCore.Shared.Items[itemName], 'remove') local pos = GetEntityCoords(PlayerPedId()) print("Starte Feuerwerk an Position: " .. pos.x .. ", " .. pos.y .. ", " .. pos.z) startFirework(assetName, pos) end, function() -- Cancel StopAnimTask(PlayerPedId(), 'anim@narcotics@trash', 'drop_front', 1.0) QBCore.Functions.Notify(Lang:t('firework.canceled'), 'error') end) end) RegisterCommand('testeffect', function() local playerPed = PlayerPedId() local coords = GetEntityCoords(playerPed) -- Einfacher, garantiert funktionierender Effekt RequestNamedPtfxAsset("core") while not HasNamedPtfxAssetLoaded("core") do Wait(10) end UseParticleFxAssetNextCall("core") local effect = StartParticleFxLoopedAtCoord("ent_sht_flame", coords.x, coords.y, coords.z + 0.5, 0.0, 0.0, 0.0, 2.0, -- scale false, false, false, false) print("Test-Effekt gestartet: " .. tostring(effect)) -- Effekt nach 5 Sekunden stoppen Citizen.SetTimeout(5000, function() StopParticleFxLooped(effect, 0) end) end)