1
0
Fork 0
forked from Simnation/Main

Update fireworks.lua

This commit is contained in:
Nordi98 2025-07-02 16:16:40 +02:00
parent 9ed6fbd344
commit 8bbeaa9bd0

View file

@ -62,33 +62,79 @@ local function fireworkText()
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 -= 1
fireworkTime = fireworkTime - 1
end
-- Debug-Nachricht hinzugefügt
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)]
-- Debug-Nachricht hinzugefügt
print("Starte Feuerwerk-Effekt: " .. firework)
print("Starte Feuerwerk-Effekt: " .. firework .. " auf Höhe: " .. height)
-- Stelle sicher, dass das Asset für jeden Effekt aktiviert wird
UseParticleFxAssetNextCall(asset)
StartNetworkedParticleFxNonLoopedAtCoord(firework, fireworkLoc.x, fireworkLoc.y, fireworkLoc.z + 42.5, 0.0, 0.0, 0.0, math.random() * 0.3 + 0.5, false, false, false)
Wait(math.random(100, 500)) -- Feste Werte für bessere Konsistenz
-- 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',
@ -99,20 +145,25 @@ CreateThread(function()
for i = 1, #assets do
local asset = assets[i]
if not HasNamedPtfxAssetLoaded(asset) then
print("Lade Asset: " .. asset)
RequestNamedPtfxAsset(asset)
while not HasNamedPtfxAssetLoaded(asset) do
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
-- Debug-Nachricht hinzugefügt
print("Alle Feuerwerk-Assets geladen")
end)
RegisterNetEvent('fireworks:client:UseFirework', function(itemName, assetName)
-- Debug-Nachricht hinzugefügt
print("Feuerwerk-Event ausgelöst mit Item: " .. itemName .. " und Asset: " .. assetName)
QBCore.Functions.Progressbar('spawn_object', Lang:t('firework.place_progress'), 3000, false, true, {
@ -130,7 +181,6 @@ RegisterNetEvent('fireworks:client:UseFirework', function(itemName, assetName)
TriggerEvent('qb-inventory:client:ItemBox', QBCore.Shared.Items[itemName], 'remove')
local pos = GetEntityCoords(PlayerPedId())
-- Debug-Nachricht hinzugefügt
print("Starte Feuerwerk an Position: " .. pos.x .. ", " .. pos.y .. ", " .. pos.z)
startFirework(assetName, pos)