2025-06-07 08:51:21 +02:00
|
|
|
local QBCore = exports['qb-core']:GetCoreObject()
|
|
|
|
local fireworkTime = 0
|
|
|
|
local fireworkLoc = nil
|
2025-07-02 16:24:15 +02:00
|
|
|
|
2025-07-02 16:51:27 +02:00
|
|
|
-- Modelle für Feuerwerks-Batterien und Raketen
|
|
|
|
local fireworkModels = {
|
|
|
|
["firework1"] = "ind_prop_firework_01", -- Rakete für firework1
|
|
|
|
["firework2"] = "ind_prop_firework_04", -- Standard-Batterie für firework2
|
|
|
|
["firework3"] = "ind_prop_firework_03", -- Große Batterie für firework3
|
|
|
|
["firework4"] = "prop_firework_03" -- Alternative Batterie für firework4
|
2025-07-02 16:24:15 +02:00
|
|
|
}
|
|
|
|
|
2025-07-02 16:41:58 +02:00
|
|
|
-- Verbesserte Feuerwerkseffekte ohne Flammen
|
|
|
|
local fireworkEffects = {
|
|
|
|
-- Bunte Explosionseffekte
|
|
|
|
"scr_indep_firework_starburst",
|
|
|
|
"scr_indep_firework_shotburst",
|
|
|
|
"scr_indep_firework_trailburst",
|
|
|
|
"scr_xmas_firework_burst_fizzle",
|
|
|
|
"scr_firework_indep_burst_rwb",
|
|
|
|
"scr_firework_indep_spiral_burst_rwb",
|
|
|
|
"scr_firework_indep_ring_burst_rwb",
|
|
|
|
-- Konfetti und Funken
|
|
|
|
"scr_indep_firework_sparkle_spawn",
|
|
|
|
"scr_xmas_firework_sparkle_spawn",
|
|
|
|
-- Trails
|
|
|
|
"proj_indep_flare_trail",
|
|
|
|
"scr_indep_firework_trail_spawn"
|
2025-06-07 08:51:21 +02:00
|
|
|
}
|
|
|
|
|
2025-07-02 16:51:27 +02:00
|
|
|
-- Funktion zum Starten einer Feuerwerksrakete
|
|
|
|
local function launchFireworkRocket(coords)
|
|
|
|
-- Lade das Raketenmodell
|
|
|
|
local rocketModel = "ind_prop_firework_01"
|
|
|
|
RequestModel(GetHashKey(rocketModel))
|
|
|
|
while not HasModelLoaded(GetHashKey(rocketModel)) do
|
|
|
|
Wait(10)
|
|
|
|
end
|
2025-07-02 16:41:58 +02:00
|
|
|
|
2025-07-02 16:51:27 +02:00
|
|
|
-- Erstelle die Rakete
|
|
|
|
local rocket = CreateObject(GetHashKey(rocketModel),
|
|
|
|
coords.x, coords.y, coords.z - 0.5,
|
|
|
|
true, true, false)
|
|
|
|
|
|
|
|
-- Stelle die Rakete richtig auf den Boden
|
|
|
|
PlaceObjectOnGroundProperly(rocket)
|
|
|
|
FreezeEntityPosition(rocket, true)
|
|
|
|
|
|
|
|
-- Warte kurz, damit die Rakete sichtbar ist
|
|
|
|
Wait(500)
|
|
|
|
|
|
|
|
-- Lade die Feuerwerkseffekte
|
|
|
|
local ptfxAssets = {
|
|
|
|
"scr_indep_fireworks",
|
|
|
|
"proj_xmas_firework",
|
|
|
|
"proj_indep_firework_v2",
|
|
|
|
"proj_indep_firework"
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, asset in ipairs(ptfxAssets) do
|
|
|
|
RequestNamedPtfxAsset(asset)
|
|
|
|
while not HasNamedPtfxAssetLoaded(asset) do
|
|
|
|
Wait(10)
|
|
|
|
end
|
2025-07-02 16:41:58 +02:00
|
|
|
end
|
|
|
|
|
2025-07-02 16:51:27 +02:00
|
|
|
-- Füge einen Zündungseffekt hinzu (kleiner Funke statt Flamme)
|
|
|
|
UseParticleFxAssetNextCall("scr_indep_fireworks")
|
|
|
|
local ignitionEffect = StartParticleFxLoopedOnEntity("scr_indep_firework_sparkle_spawn",
|
|
|
|
rocket, 0.0, 0.0, 0.2, 0.0, 0.0, 0.0, 0.5, false, false, false)
|
|
|
|
|
|
|
|
-- Zündungsgeräusch
|
|
|
|
PlaySoundFromEntity(-1, "DISTANT_FIREWORK_LAUNCH_01", rocket, "dlc_sum20_beach_party_sounds", true, 20)
|
|
|
|
|
|
|
|
-- Warte kurz für den Zündungseffekt
|
|
|
|
Wait(1000)
|
|
|
|
|
|
|
|
-- Stoppe den Zündungseffekt
|
|
|
|
StopParticleFxLooped(ignitionEffect, 0)
|
|
|
|
|
|
|
|
-- Löse die Rakete vom Boden
|
|
|
|
FreezeEntityPosition(rocket, false)
|
|
|
|
|
|
|
|
-- Füge einen Aufstiegseffekt hinzu
|
|
|
|
UseParticleFxAssetNextCall("scr_indep_fireworks")
|
|
|
|
local trailEffect = StartParticleFxLoopedOnEntity("scr_indep_firework_trail_spawn",
|
|
|
|
rocket, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, false, false, false)
|
|
|
|
|
|
|
|
-- Bewege die Rakete nach oben
|
|
|
|
local startTime = GetGameTimer()
|
|
|
|
local duration = 3000 -- 3 Sekunden Aufstieg
|
|
|
|
local height = math.random(40, 60)
|
|
|
|
local startZ = GetEntityCoords(rocket).z
|
|
|
|
|
|
|
|
-- Aufstiegsschleife mit leichter Schwankung
|
|
|
|
while GetGameTimer() - startTime < duration do
|
|
|
|
local progress = (GetGameTimer() - startTime) / duration
|
|
|
|
local newZ = startZ + (height * progress)
|
|
|
|
|
|
|
|
-- Leichte Schwankung für realistischen Flug
|
|
|
|
local wobbleX = math.sin(GetGameTimer() * 0.01) * 0.3 * progress
|
|
|
|
local wobbleY = math.cos(GetGameTimer() * 0.01) * 0.3 * progress
|
|
|
|
|
|
|
|
SetEntityCoords(rocket,
|
|
|
|
coords.x + wobbleX,
|
|
|
|
coords.y + wobbleY,
|
|
|
|
newZ)
|
|
|
|
Wait(0)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Stoppe den Aufstiegseffekt
|
|
|
|
StopParticleFxLooped(trailEffect, 0)
|
|
|
|
|
|
|
|
-- Verstecke die Rakete
|
|
|
|
SetEntityVisible(rocket, false, 0)
|
|
|
|
|
|
|
|
-- Explosionseffekt in der Luft
|
|
|
|
local explosionHeight = startZ + height
|
|
|
|
|
|
|
|
-- Wähle mehrere zufällige Effekte für die Explosion
|
|
|
|
for i = 1, 5 do
|
|
|
|
-- Wähle einen zufälligen Effekt aus der Liste
|
|
|
|
local effectIndex = math.random(1, #fireworkEffects)
|
|
|
|
local effect = fireworkEffects[effectIndex]
|
|
|
|
|
|
|
|
-- Bestimme das richtige Asset für diesen Effekt
|
|
|
|
local effectAsset = "scr_indep_fireworks" -- Standard
|
|
|
|
|
|
|
|
if effect:find("xmas") then
|
|
|
|
effectAsset = "proj_xmas_firework"
|
|
|
|
elseif effect:find("indep_burst") or effect:find("indep_spiral") or effect:find("indep_ring") then
|
|
|
|
effectAsset = "proj_indep_firework_v2"
|
|
|
|
elseif effect:find("flare") then
|
|
|
|
effectAsset = "proj_indep_firework"
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Leichte Variation in der Position
|
|
|
|
local offsetX = math.random(-5, 5)
|
|
|
|
local offsetY = math.random(-5, 5)
|
|
|
|
local offsetZ = math.random(-5, 5)
|
|
|
|
|
|
|
|
-- Starte den Effekt
|
|
|
|
UseParticleFxAssetNextCall(effectAsset)
|
|
|
|
StartParticleFxNonLoopedAtCoord(
|
|
|
|
effect,
|
|
|
|
coords.x + offsetX, coords.y + offsetY, explosionHeight + offsetZ,
|
|
|
|
0.0, 0.0, 0.0,
|
|
|
|
math.random(20, 30) / 10, -- Größere Skalierung für bessere Sichtbarkeit
|
|
|
|
false, false, false
|
|
|
|
)
|
|
|
|
|
|
|
|
-- Explosionsgeräusch
|
|
|
|
PlaySoundFromCoord(-1, "DISTANT_FIREWORK_BURST_0" .. math.random(1, 3),
|
|
|
|
coords.x + offsetX, coords.y + offsetY, explosionHeight + offsetZ,
|
|
|
|
"dlc_sum20_beach_party_sounds", true, 50, false)
|
|
|
|
|
|
|
|
Wait(math.random(100, 300))
|
2025-07-02 17:01:45 +02:00
|
|
|
|
2025-07-02 16:51:27 +02:00
|
|
|
|
|
|
|
-- Lösche die Rakete nach einer Weile
|
|
|
|
Wait(5000)
|
|
|
|
DeleteEntity(rocket)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Funktion zum Starten einer Feuerwerks-Batterie ohne Flammeneffekte
|
|
|
|
local function startFireworkBattery(coords, itemName)
|
|
|
|
-- Wähle ein Batteriemodell basierend auf dem Item
|
|
|
|
local batteryModel = fireworkModels[itemName] or "ind_prop_firework_04" -- Standard, falls nicht definiert
|
|
|
|
|
2025-07-02 16:41:58 +02:00
|
|
|
print("Verwende Batteriemodell: " .. batteryModel)
|
2025-07-02 16:24:15 +02:00
|
|
|
|
|
|
|
-- Lade das Modell
|
2025-07-02 16:34:41 +02:00
|
|
|
RequestModel(GetHashKey(batteryModel))
|
|
|
|
while not HasModelLoaded(GetHashKey(batteryModel)) do
|
2025-07-02 16:24:15 +02:00
|
|
|
Wait(10)
|
|
|
|
end
|
|
|
|
|
2025-07-02 16:34:41 +02:00
|
|
|
-- Erstelle die Batterie
|
|
|
|
local battery = CreateObject(GetHashKey(batteryModel),
|
|
|
|
coords.x, coords.y, coords.z - 0.5, -- Leicht in den Boden eingelassen
|
2025-07-02 16:24:15 +02:00
|
|
|
true, true, false)
|
|
|
|
|
2025-07-02 16:34:41 +02:00
|
|
|
-- Stelle die Batterie richtig auf den Boden
|
|
|
|
PlaceObjectOnGroundProperly(battery)
|
|
|
|
FreezeEntityPosition(battery, true)
|
2025-07-02 16:24:15 +02:00
|
|
|
|
2025-07-02 16:34:41 +02:00
|
|
|
-- Warte kurz, damit die Batterie sichtbar ist
|
2025-07-02 16:24:15 +02:00
|
|
|
Wait(500)
|
|
|
|
|
2025-07-02 16:41:58 +02:00
|
|
|
-- Lade die Feuerwerkseffekte
|
|
|
|
local ptfxAssets = {
|
|
|
|
"scr_indep_fireworks",
|
|
|
|
"proj_xmas_firework",
|
|
|
|
"proj_indep_firework_v2",
|
|
|
|
"proj_indep_firework"
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, asset in ipairs(ptfxAssets) do
|
|
|
|
RequestNamedPtfxAsset(asset)
|
|
|
|
while not HasNamedPtfxAssetLoaded(asset) do
|
|
|
|
Wait(10)
|
|
|
|
end
|
2025-07-02 16:24:15 +02:00
|
|
|
end
|
|
|
|
|
2025-07-02 16:41:58 +02:00
|
|
|
-- Füge einen Zündungseffekt hinzu (kleiner Funke statt Flamme)
|
|
|
|
UseParticleFxAssetNextCall("scr_indep_fireworks")
|
|
|
|
local ignitionEffect = StartParticleFxLoopedOnEntity("scr_indep_firework_sparkle_spawn",
|
2025-07-02 16:34:41 +02:00
|
|
|
battery, 0.0, 0.0, 0.2, 0.0, 0.0, 0.0, 0.5, false, false, false)
|
2025-07-02 16:24:15 +02:00
|
|
|
|
|
|
|
-- Zündungsgeräusch
|
2025-07-02 16:34:41 +02:00
|
|
|
PlaySoundFromEntity(-1, "DISTANT_FIREWORK_LAUNCH_01", battery, "dlc_sum20_beach_party_sounds", true, 20)
|
2025-07-02 16:24:15 +02:00
|
|
|
|
|
|
|
-- Warte kurz für den Zündungseffekt
|
|
|
|
Wait(1000)
|
|
|
|
|
|
|
|
-- Stoppe den Zündungseffekt
|
|
|
|
StopParticleFxLooped(ignitionEffect, 0)
|
|
|
|
|
2025-07-02 16:51:27 +02:00
|
|
|
-- Bestimme die Anzahl der Schüsse basierend auf dem Item
|
2025-07-02 16:41:58 +02:00
|
|
|
local numShots = 15 -- Standard
|
|
|
|
|
|
|
|
if itemName == "firework3" then
|
2025-07-02 16:51:27 +02:00
|
|
|
numShots = 30 -- Mehr Schüsse für firework3 (große Batterie)
|
|
|
|
elseif itemName == "firework2" then
|
|
|
|
numShots = 15 -- Standard für firework2
|
|
|
|
elseif itemName == "firework4" then
|
|
|
|
numShots = 20 -- Etwas mehr für firework4
|
2025-07-02 16:24:15 +02:00
|
|
|
end
|
|
|
|
|
2025-07-02 16:34:41 +02:00
|
|
|
print("Starte Feuerwerks-Batterie mit " .. numShots .. " Schüssen")
|
|
|
|
|
|
|
|
-- Starte die Feuerwerksschüsse
|
|
|
|
for i = 1, numShots do
|
|
|
|
-- Bestimme die Höhe und Position des Schusses
|
|
|
|
local height = math.random(30, 50)
|
|
|
|
local offsetX = math.random(-10, 10) * (i / numShots) -- Größere Streuung bei späteren Schüssen
|
|
|
|
local offsetY = math.random(-10, 10) * (i / numShots)
|
|
|
|
|
2025-07-02 16:41:58 +02:00
|
|
|
-- Starteffekt (kleiner Funke statt Flamme)
|
|
|
|
UseParticleFxAssetNextCall("scr_indep_fireworks")
|
|
|
|
StartParticleFxNonLoopedAtCoord("scr_indep_firework_sparkle_spawn",
|
2025-07-02 16:34:41 +02:00
|
|
|
coords.x, coords.y, coords.z + 0.5,
|
|
|
|
0.0, 0.0, 0.0,
|
|
|
|
0.8, false, false, false)
|
2025-07-02 16:24:15 +02:00
|
|
|
|
2025-07-02 16:34:41 +02:00
|
|
|
-- Abschussgeräusch
|
|
|
|
PlaySoundFromEntity(-1, "DISTANT_FIREWORK_LAUNCH_01", battery, "dlc_sum20_beach_party_sounds", true, 20)
|
|
|
|
|
|
|
|
-- Warte kurz für den visuellen Effekt des Aufstiegs
|
|
|
|
Wait(math.random(100, 200))
|
|
|
|
|
|
|
|
-- Explosionseffekt in der Luft (nur Partikel, keine echte Explosion)
|
|
|
|
local explosionHeight = coords.z + height
|
|
|
|
|
2025-07-02 16:41:58 +02:00
|
|
|
-- Wähle einen zufälligen Effekt aus der Liste
|
|
|
|
local effectIndex = math.random(1, #fireworkEffects)
|
|
|
|
local effect = fireworkEffects[effectIndex]
|
|
|
|
|
|
|
|
-- Bestimme das richtige Asset für diesen Effekt
|
|
|
|
local effectAsset = "scr_indep_fireworks" -- Standard
|
|
|
|
|
|
|
|
if effect:find("xmas") then
|
|
|
|
effectAsset = "proj_xmas_firework"
|
|
|
|
elseif effect:find("indep_burst") or effect:find("indep_spiral") or effect:find("indep_ring") then
|
|
|
|
effectAsset = "proj_indep_firework_v2"
|
|
|
|
elseif effect:find("flare") then
|
|
|
|
effectAsset = "proj_indep_firework"
|
|
|
|
end
|
2025-07-02 16:34:41 +02:00
|
|
|
|
|
|
|
-- Starte den Haupteffekt
|
2025-07-02 16:41:58 +02:00
|
|
|
UseParticleFxAssetNextCall(effectAsset)
|
2025-07-02 16:24:15 +02:00
|
|
|
StartParticleFxNonLoopedAtCoord(
|
2025-07-02 16:34:41 +02:00
|
|
|
effect,
|
|
|
|
coords.x + offsetX, coords.y + offsetY, explosionHeight,
|
2025-07-02 16:24:15 +02:00
|
|
|
0.0, 0.0, 0.0,
|
2025-07-02 16:34:41 +02:00
|
|
|
math.random(20, 30) / 10, -- Größere Skalierung für bessere Sichtbarkeit
|
2025-07-02 16:24:15 +02:00
|
|
|
false, false, false
|
|
|
|
)
|
|
|
|
|
2025-07-02 16:34:41 +02:00
|
|
|
-- Füge zusätzliche Effekte für mehr Volumen hinzu
|
2025-07-02 16:41:58 +02:00
|
|
|
for j = 1, 2 do
|
2025-07-02 16:34:41 +02:00
|
|
|
local subOffsetX = math.random(-3, 3)
|
|
|
|
local subOffsetY = math.random(-3, 3)
|
|
|
|
local subOffsetZ = math.random(-3, 3)
|
|
|
|
|
2025-07-02 16:41:58 +02:00
|
|
|
-- Wähle einen anderen zufälligen Effekt
|
|
|
|
local subEffectIndex = math.random(1, #fireworkEffects)
|
|
|
|
local subEffect = fireworkEffects[subEffectIndex]
|
|
|
|
|
|
|
|
-- Bestimme das richtige Asset für diesen Effekt
|
|
|
|
local subEffectAsset = "scr_indep_fireworks" -- Standard
|
|
|
|
|
|
|
|
if subEffect:find("xmas") then
|
|
|
|
subEffectAsset = "proj_xmas_firework"
|
|
|
|
elseif subEffect:find("indep_burst") or subEffect:find("indep_spiral") or subEffect:find("indep_ring") then
|
|
|
|
subEffectAsset = "proj_indep_firework_v2"
|
|
|
|
elseif subEffect:find("flare") then
|
|
|
|
subEffectAsset = "proj_indep_firework"
|
|
|
|
end
|
|
|
|
|
|
|
|
UseParticleFxAssetNextCall(subEffectAsset)
|
2025-07-02 16:34:41 +02:00
|
|
|
StartParticleFxNonLoopedAtCoord(
|
2025-07-02 16:41:58 +02:00
|
|
|
subEffect,
|
2025-07-02 16:34:41 +02:00
|
|
|
coords.x + offsetX + subOffsetX,
|
|
|
|
coords.y + offsetY + subOffsetY,
|
|
|
|
explosionHeight + subOffsetZ,
|
|
|
|
0.0, 0.0, 0.0,
|
|
|
|
math.random(15, 25) / 10,
|
|
|
|
false, false, false
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2025-07-02 16:24:15 +02:00
|
|
|
-- Explosionsgeräusch
|
|
|
|
PlaySoundFromCoord(-1, "DISTANT_FIREWORK_BURST_0" .. math.random(1, 3),
|
2025-07-02 16:34:41 +02:00
|
|
|
coords.x + offsetX, coords.y + offsetY, explosionHeight,
|
|
|
|
"dlc_sum20_beach_party_sounds", true, 50, false)
|
|
|
|
|
|
|
|
-- Warte zwischen den Schüssen
|
|
|
|
-- Schnellere Abfolge gegen Ende für ein Finale
|
|
|
|
local waitTime = 0
|
|
|
|
if i < numShots * 0.7 then
|
|
|
|
waitTime = math.random(300, 800)
|
|
|
|
else
|
|
|
|
waitTime = math.random(100, 300)
|
|
|
|
end
|
|
|
|
Wait(waitTime)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Warte nach dem letzten Schuss
|
|
|
|
Wait(2000)
|
|
|
|
|
|
|
|
-- Finale mit mehreren gleichzeitigen Effekten
|
|
|
|
for i = 1, 8 do
|
|
|
|
local finalOffsetX = math.random(-15, 15)
|
|
|
|
local finalOffsetY = math.random(-15, 15)
|
|
|
|
local finalHeight = math.random(30, 50)
|
|
|
|
|
2025-07-02 16:41:58 +02:00
|
|
|
-- Wähle einen zufälligen Effekt für das Finale
|
|
|
|
local finalEffectIndex = math.random(1, #fireworkEffects)
|
|
|
|
local finalEffect = fireworkEffects[finalEffectIndex]
|
|
|
|
|
|
|
|
-- Bestimme das richtige Asset für diesen Effekt
|
|
|
|
local finalEffectAsset = "scr_indep_fireworks" -- Standard
|
|
|
|
|
|
|
|
if finalEffect:find("xmas") then
|
|
|
|
finalEffectAsset = "proj_xmas_firework"
|
|
|
|
elseif finalEffect:find("indep_burst") or finalEffect:find("indep_spiral") or finalEffect:find("indep_ring") then
|
|
|
|
finalEffectAsset = "proj_indep_firework_v2"
|
|
|
|
elseif finalEffect:find("flare") then
|
|
|
|
finalEffectAsset = "proj_indep_firework"
|
|
|
|
end
|
|
|
|
|
|
|
|
UseParticleFxAssetNextCall(finalEffectAsset)
|
2025-07-02 16:34:41 +02:00
|
|
|
StartParticleFxNonLoopedAtCoord(
|
2025-07-02 16:41:58 +02:00
|
|
|
finalEffect,
|
2025-07-02 16:34:41 +02:00
|
|
|
coords.x + finalOffsetX,
|
|
|
|
coords.y + finalOffsetY,
|
|
|
|
coords.z + finalHeight,
|
|
|
|
0.0, 0.0, 0.0,
|
|
|
|
math.random(25, 35) / 10, -- Größere Skalierung für das Finale
|
|
|
|
false, false, false
|
|
|
|
)
|
|
|
|
|
|
|
|
-- Finale-Geräusch
|
|
|
|
PlaySoundFromCoord(-1, "DISTANT_FIREWORK_BURST_0" .. math.random(1, 3),
|
|
|
|
coords.x + finalOffsetX, coords.y + finalOffsetY, coords.z + finalHeight,
|
2025-07-02 16:24:15 +02:00
|
|
|
"dlc_sum20_beach_party_sounds", true, 50, false)
|
|
|
|
|
2025-07-02 16:34:41 +02:00
|
|
|
Wait(100)
|
2025-07-02 16:24:15 +02:00
|
|
|
end
|
|
|
|
|
2025-07-02 16:34:41 +02:00
|
|
|
-- Lösche die Batterie nach einer Weile
|
2025-07-02 16:24:15 +02:00
|
|
|
Wait(5000)
|
2025-07-02 16:34:41 +02:00
|
|
|
DeleteEntity(battery)
|
2025-07-02 16:24:15 +02:00
|
|
|
end
|
|
|
|
|
2025-06-07 08:51:21 +02:00
|
|
|
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
|
|
|
|
|
2025-07-02 16:24:15 +02:00
|
|
|
-- Verbesserte Feuerwerk-Startfunktion
|
2025-07-02 16:41:58 +02:00
|
|
|
local function startFirework(asset, coords, itemName)
|
2025-06-07 08:51:21 +02:00
|
|
|
fireworkTime = Config.Fireworks.delay
|
|
|
|
fireworkLoc = { x = coords.x, y = coords.y, z = coords.z }
|
2025-07-02 16:16:40 +02:00
|
|
|
|
2025-06-07 08:51:21 +02:00
|
|
|
CreateThread(function()
|
|
|
|
fireworkText()
|
|
|
|
while fireworkTime > 0 do
|
|
|
|
Wait(1000)
|
2025-07-02 16:16:40 +02:00
|
|
|
fireworkTime = fireworkTime - 1
|
2025-06-07 08:51:21 +02:00
|
|
|
end
|
2025-06-22 17:32:14 +02:00
|
|
|
|
2025-07-02 16:51:27 +02:00
|
|
|
print("Countdown beendet, starte Feuerwerk: " .. itemName)
|
2025-06-22 17:32:14 +02:00
|
|
|
|
2025-07-02 16:51:27 +02:00
|
|
|
-- Wähle die richtige Feuerwerksart basierend auf dem Item
|
|
|
|
if itemName == "firework1" then
|
|
|
|
-- Rakete für firework1
|
|
|
|
launchFireworkRocket(coords)
|
|
|
|
else
|
|
|
|
-- Batterie für alle anderen
|
|
|
|
startFireworkBattery(coords, itemName)
|
2025-07-02 16:24:15 +02:00
|
|
|
end
|
2025-07-02 16:16:40 +02:00
|
|
|
|
2025-06-07 08:51:21 +02:00
|
|
|
fireworkLoc = nil
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
2025-07-02 16:34:41 +02:00
|
|
|
-- Animation für das Anzünden mit Feuerzeug
|
|
|
|
local function playLighterAnimation()
|
|
|
|
local ped = PlayerPedId()
|
|
|
|
|
|
|
|
-- Lade die Animation
|
|
|
|
RequestAnimDict("anim@mp_player_intmenu@key_fob@")
|
|
|
|
while not HasAnimDictLoaded("anim@mp_player_intmenu@key_fob@") do
|
|
|
|
Wait(10)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Spiele die Animation ab
|
|
|
|
TaskPlayAnim(ped, "anim@mp_player_intmenu@key_fob@", "fob_click", 3.0, 3.0, -1, 49, 0, false, false, false)
|
|
|
|
|
|
|
|
-- Erstelle ein Feuerzeug-Objekt in der Hand
|
|
|
|
local coords = GetEntityCoords(ped)
|
|
|
|
local lighter = CreateObject(GetHashKey("prop_cs_lighter_01"), coords.x, coords.y, coords.z, true, true, true)
|
|
|
|
AttachEntityToEntity(lighter, ped, GetPedBoneIndex(ped, 57005), 0.1, 0.05, 0.0, -60.0, 0.0, 0.0, true, true, false, true, 1, true)
|
|
|
|
|
2025-07-02 16:41:58 +02:00
|
|
|
-- Füge einen kleinen Funkeneffekt statt Flamme hinzu
|
|
|
|
RequestNamedPtfxAsset("scr_indep_fireworks")
|
|
|
|
while not HasNamedPtfxAssetLoaded("scr_indep_fireworks") do
|
2025-07-02 16:34:41 +02:00
|
|
|
Wait(10)
|
|
|
|
end
|
|
|
|
|
2025-07-02 16:41:58 +02:00
|
|
|
UseParticleFxAssetNextCall("scr_indep_fireworks")
|
|
|
|
local spark = StartParticleFxLoopedOnEntity("scr_indep_firework_sparkle_spawn", lighter, 0.0, 0.0, 0.15, 0.0, 0.0, 0.0, 0.15, false, false, false)
|
2025-07-02 16:34:41 +02:00
|
|
|
|
|
|
|
-- Warte 2 Sekunden
|
|
|
|
Wait(2000)
|
|
|
|
|
|
|
|
-- Stoppe die Animation und lösche das Feuerzeug
|
|
|
|
StopAnimTask(ped, "anim@mp_player_intmenu@key_fob@", "fob_click", 1.0)
|
2025-07-02 16:41:58 +02:00
|
|
|
StopParticleFxLooped(spark, 0)
|
2025-07-02 16:34:41 +02:00
|
|
|
DeleteEntity(lighter)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Überprüfe, ob der Spieler ein Feuerzeug hat
|
|
|
|
local function hasLighter()
|
|
|
|
local hasItem = QBCore.Functions.HasItem("lighter")
|
|
|
|
return hasItem
|
|
|
|
end
|
|
|
|
|
2025-06-07 08:51:21 +02:00
|
|
|
RegisterNetEvent('fireworks:client:UseFirework', function(itemName, assetName)
|
2025-07-02 16:24:15 +02:00
|
|
|
print("Feuerwerk-Event ausgelöst mit Item: " .. itemName)
|
2025-06-22 17:32:14 +02:00
|
|
|
|
2025-07-02 16:34:41 +02:00
|
|
|
-- Überprüfe zuerst, ob der Spieler ein Feuerzeug hat
|
|
|
|
if not hasLighter() then
|
|
|
|
QBCore.Functions.Notify(Lang:t('firework.no_lighter'), 'error')
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2025-06-07 08:51:21 +02:00
|
|
|
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())
|
2025-06-22 17:32:14 +02:00
|
|
|
|
2025-07-02 16:34:41 +02:00
|
|
|
print("Feuerwerk platziert, beginne Anzündung")
|
|
|
|
|
|
|
|
-- Spiele die Feuerzeug-Animation ab
|
|
|
|
playLighterAnimation()
|
2025-06-22 17:32:14 +02:00
|
|
|
|
2025-07-02 16:41:58 +02:00
|
|
|
-- Starte das Feuerwerk mit dem Itemnamen
|
|
|
|
startFirework(assetName, pos, itemName)
|
2025-06-07 08:51:21 +02:00
|
|
|
end, function() -- Cancel
|
|
|
|
StopAnimTask(PlayerPedId(), 'anim@narcotics@trash', 'drop_front', 1.0)
|
|
|
|
QBCore.Functions.Notify(Lang:t('firework.canceled'), 'error')
|
|
|
|
end)
|
|
|
|
end)
|
2025-07-02 16:24:15 +02:00
|
|
|
|
2025-07-02 16:51:27 +02:00
|
|
|
-- Test-Befehl für verschiedene Feuerwerkstypen
|
|
|
|
RegisterCommand('feuerwerk', function(source, args)
|
|
|
|
local playerPed = PlayerPedId()
|
|
|
|
local coords = GetEntityCoords(playerPed)
|
|
|
|
|
|
|
|
-- Überprüfe zuerst, ob der Spieler ein Feuerzeug hat
|
|
|
|
if not hasLighter() then
|
|
|
|
QBCore.Functions.Notify(Lang:t('firework.no_lighter'), 'error')
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Item-Name als Argument
|
|
|
|
local itemName = args[1] or "firework1"
|
|
|
|
|
|
|
|
-- Spiele die Feuerzeug-Animation ab
|
|
|
|
playLighterAnimation()
|
|
|
|
|
|
|
|
-- Starte das passende Feuerwerk
|
|
|
|
if itemName == "firework1" then
|
|
|
|
launchFireworkRocket(coords)
|
|
|
|
else
|
|
|
|
startFireworkBattery(coords, itemName)
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- Spezielle Test-Befehle für die verschiedenen Feuerwerkstypen
|
|
|
|
RegisterCommand('rakete', function()
|
2025-07-02 16:19:35 +02:00
|
|
|
local playerPed = PlayerPedId()
|
|
|
|
local coords = GetEntityCoords(playerPed)
|
|
|
|
|
2025-07-02 16:34:41 +02:00
|
|
|
-- Überprüfe zuerst, ob der Spieler ein Feuerzeug hat
|
|
|
|
if not hasLighter() then
|
|
|
|
QBCore.Functions.Notify(Lang:t('firework.no_lighter'), 'error')
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2025-07-02 16:51:27 +02:00
|
|
|
-- Spiele die Feuerzeug-Animation ab
|
|
|
|
playLighterAnimation()
|
2025-07-02 16:19:35 +02:00
|
|
|
|
2025-07-02 16:51:27 +02:00
|
|
|
-- Starte die Rakete (firework1)
|
|
|
|
launchFireworkRocket(coords)
|
|
|
|
end)
|
|
|
|
|
|
|
|
RegisterCommand('batterie', function()
|
|
|
|
local playerPed = PlayerPedId()
|
|
|
|
local coords = GetEntityCoords(playerPed)
|
|
|
|
|
|
|
|
-- Überprüfe zuerst, ob der Spieler ein Feuerzeug hat
|
|
|
|
if not hasLighter() then
|
|
|
|
QBCore.Functions.Notify(Lang:t('firework.no_lighter'), 'error')
|
|
|
|
return
|
|
|
|
end
|
2025-07-02 16:41:58 +02:00
|
|
|
|
2025-07-02 16:34:41 +02:00
|
|
|
-- Spiele die Feuerzeug-Animation ab
|
|
|
|
playLighterAnimation()
|
|
|
|
|
2025-07-02 16:51:27 +02:00
|
|
|
-- Starte die Standard-Batterie (firework2)
|
|
|
|
startFireworkBattery(coords, "firework2")
|
2025-07-02 16:41:58 +02:00
|
|
|
end)
|
|
|
|
|
2025-07-02 16:51:27 +02:00
|
|
|
RegisterCommand('grossebatterie', function()
|
2025-07-02 16:41:58 +02:00
|
|
|
local playerPed = PlayerPedId()
|
|
|
|
local coords = GetEntityCoords(playerPed)
|
|
|
|
|
|
|
|
-- Überprüfe zuerst, ob der Spieler ein Feuerzeug hat
|
|
|
|
if not hasLighter() then
|
|
|
|
QBCore.Functions.Notify(Lang:t('firework.no_lighter'), 'error')
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Spiele die Feuerzeug-Animation ab
|
|
|
|
playLighterAnimation()
|
|
|
|
|
2025-07-02 16:51:27 +02:00
|
|
|
-- Starte die große Batterie (firework3)
|
|
|
|
startFireworkBattery(coords, "firework3")
|
2025-07-02 16:19:35 +02:00
|
|
|
end)
|