1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-07-02 16:41:58 +02:00
parent dacaa0d819
commit 837125a876

View file

@ -6,25 +6,45 @@ local fireworkLoc = nil
local batteryModels = {
"ind_prop_firework_04", -- Standard-Feuerwerks-Batterie
"ind_prop_firework_03", -- Größere Feuerwerks-Batterie
"prop_beach_fire", -- Alternative für bessere Sichtbarkeit
"prop_firework_03" -- Weitere Batterie-Option
"prop_firework_03", -- Weitere Batterie-Option
"ind_prop_firework_03" -- Große Batterie für firework3
}
-- Farben für die Feuerwerkseffekte
local colors = {
{r = 255, g = 0, b = 0}, -- Rot
{r = 0, g = 255, b = 0}, -- Grün
{r = 0, g = 0, b = 255}, -- Blau
{r = 255, g = 255, b = 0}, -- Gelb
{r = 255, g = 0, b = 255}, -- Magenta
{r = 0, g = 255, b = 255}, -- Cyan
{r = 255, g = 255, b = 255} -- Weiß
-- 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"
}
-- Funktion zum Starten einer Feuerwerks-Batterie ohne Explosionseffekte
local function startFireworkBattery(coords, type)
-- Wähle ein Batteriemodell basierend auf dem Typ oder zufällig
local batteryModel = batteryModels[type or math.random(1, #batteryModels)]
-- Funktion zum Starten einer Feuerwerks-Batterie ohne Flammeneffekte
local function startFireworkBattery(coords, type, itemName)
-- Wähle ein Batteriemodell basierend auf dem Item oder Typ
local batteryModel = "ind_prop_firework_04" -- Standard
-- Spezielle Batterie für firework3
if itemName == "firework3" then
batteryModel = "ind_prop_firework_03" -- Große Batterie
elseif type == 2 then
batteryModel = "ind_prop_firework_03"
elseif type == 3 then
batteryModel = "prop_firework_03"
elseif type == 4 then
batteryModel = "ind_prop_firework_04"
end
print("Verwende Batteriemodell: " .. batteryModel)
-- Lade das Modell
RequestModel(GetHashKey(batteryModel))
@ -44,14 +64,25 @@ local function startFireworkBattery(coords, type)
-- Warte kurz, damit die Batterie sichtbar ist
Wait(500)
-- Füge einen Zündungseffekt hinzu
RequestNamedPtfxAsset("core")
while not HasNamedPtfxAssetLoaded("core") do
-- 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
print("Asset geladen: " .. asset)
end
UseParticleFxAssetNextCall("core")
local ignitionEffect = StartParticleFxLoopedOnEntity("ent_amb_torch_fire",
-- Füge einen Zündungseffekt hinzu (kleiner Funke statt Flamme)
UseParticleFxAssetNextCall("scr_indep_fireworks")
local ignitionEffect = StartParticleFxLoopedOnEntity("scr_indep_firework_sparkle_spawn",
battery, 0.0, 0.0, 0.2, 0.0, 0.0, 0.0, 0.5, false, false, false)
-- Zündungsgeräusch
@ -63,28 +94,23 @@ local function startFireworkBattery(coords, type)
-- Stoppe den Zündungseffekt
StopParticleFxLooped(ignitionEffect, 0)
-- Bestimme die Anzahl der Schüsse basierend auf dem Typ
local numShots = 0
if type == 1 then numShots = math.random(10, 15)
elseif type == 2 then numShots = math.random(15, 20)
elseif type == 3 then numShots = math.random(20, 25)
elseif type == 4 then numShots = math.random(25, 30)
else numShots = math.random(10, 20)
-- Bestimme die Anzahl der Schüsse basierend auf dem Typ oder Item
local numShots = 15 -- Standard
if itemName == "firework3" then
numShots = 30 -- Mehr Schüsse für firework3
elseif type == 1 then
numShots = math.random(10, 15)
elseif type == 2 then
numShots = math.random(15, 20)
elseif type == 3 then
numShots = math.random(20, 25)
elseif type == 4 then
numShots = math.random(25, 30)
end
print("Starte Feuerwerks-Batterie mit " .. numShots .. " Schüssen")
-- Liste der Partikeleffekte für Feuerwerk
local fireworkEffects = {
"ent_sht_flame",
"ent_sht_confetti",
"ent_sht_steam",
"ent_dst_gen_firework",
"ent_ray_heli_aprtmnt_l_fire",
"ent_ray_heli_aprtmnt_h_fire",
"proj_flare_trail"
}
-- Starte die Feuerwerksschüsse
for i = 1, numShots do
-- Bestimme die Höhe und Position des Schusses
@ -92,9 +118,12 @@ local function startFireworkBattery(coords, type)
local offsetX = math.random(-10, 10) * (i / numShots) -- Größere Streuung bei späteren Schüssen
local offsetY = math.random(-10, 10) * (i / numShots)
-- Starteffekt (Abschuss von der Batterie)
UseParticleFxAssetNextCall("core")
StartParticleFxNonLoopedAtCoord("ent_sht_flame",
-- Wähle ein zufälliges Asset für diesen Schuss
local selectedAsset = ptfxAssets[math.random(1, #ptfxAssets)]
-- Starteffekt (kleiner Funke statt Flamme)
UseParticleFxAssetNextCall("scr_indep_fireworks")
StartParticleFxNonLoopedAtCoord("scr_indep_firework_sparkle_spawn",
coords.x, coords.y, coords.z + 0.5,
0.0, 0.0, 0.0,
0.8, false, false, false)
@ -108,11 +137,23 @@ local function startFireworkBattery(coords, type)
-- Explosionseffekt in der Luft (nur Partikel, keine echte Explosion)
local explosionHeight = coords.z + height
-- Wähle einen zufälligen Effekt
local effect = fireworkEffects[math.random(1, #fireworkEffects)]
-- 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
-- Starte den Haupteffekt
UseParticleFxAssetNextCall("core")
UseParticleFxAssetNextCall(effectAsset)
StartParticleFxNonLoopedAtCoord(
effect,
coords.x + offsetX, coords.y + offsetY, explosionHeight,
@ -122,14 +163,29 @@ local function startFireworkBattery(coords, type)
)
-- Füge zusätzliche Effekte für mehr Volumen hinzu
for j = 1, 3 do
for j = 1, 2 do
local subOffsetX = math.random(-3, 3)
local subOffsetY = math.random(-3, 3)
local subOffsetZ = math.random(-3, 3)
UseParticleFxAssetNextCall("core")
-- 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)
StartParticleFxNonLoopedAtCoord(
fireworkEffects[math.random(1, #fireworkEffects)],
subEffect,
coords.x + offsetX + subOffsetX,
coords.y + offsetY + subOffsetY,
explosionHeight + subOffsetZ,
@ -164,9 +220,24 @@ local function startFireworkBattery(coords, type)
local finalOffsetY = math.random(-15, 15)
local finalHeight = math.random(30, 50)
UseParticleFxAssetNextCall("core")
-- 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)
StartParticleFxNonLoopedAtCoord(
fireworkEffects[math.random(1, #fireworkEffects)],
finalEffect,
coords.x + finalOffsetX,
coords.y + finalOffsetY,
coords.z + finalHeight,
@ -216,7 +287,7 @@ local function fireworkText()
end
-- Verbesserte Feuerwerk-Startfunktion
local function startFirework(asset, coords)
local function startFirework(asset, coords, itemName)
fireworkTime = Config.Fireworks.delay
fireworkLoc = { x = coords.x, y = coords.y, z = coords.z }
@ -239,7 +310,7 @@ local function startFirework(asset, coords)
batteryType = 4
end
startFireworkBattery(coords, batteryType)
startFireworkBattery(coords, batteryType, itemName)
fireworkLoc = nil
end)
@ -263,21 +334,21 @@ local function playLighterAnimation()
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)
-- Füge einen Flammeneffekt hinzu
RequestNamedPtfxAsset("core")
while not HasNamedPtfxAssetLoaded("core") do
-- Füge einen kleinen Funkeneffekt statt Flamme hinzu
RequestNamedPtfxAsset("scr_indep_fireworks")
while not HasNamedPtfxAssetLoaded("scr_indep_fireworks") do
Wait(10)
end
UseParticleFxAssetNextCall("core")
local flame = StartParticleFxLoopedOnEntity("ent_amb_torch_fire", lighter, 0.0, 0.0, 0.15, 0.0, 0.0, 0.0, 0.15, false, false, false)
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)
-- 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)
StopParticleFxLooped(flame, 0)
StopParticleFxLooped(spark, 0)
DeleteEntity(lighter)
end
@ -316,8 +387,8 @@ RegisterNetEvent('fireworks:client:UseFirework', function(itemName, assetName)
-- Spiele die Feuerzeug-Animation ab
playLighterAnimation()
-- Starte das Feuerwerk
startFirework(assetName, pos)
-- Starte das Feuerwerk mit dem Itemnamen
startFirework(assetName, pos, itemName)
end, function() -- Cancel
StopAnimTask(PlayerPedId(), 'anim@narcotics@trash', 'drop_front', 1.0)
QBCore.Functions.Notify(Lang:t('firework.canceled'), 'error')
@ -339,9 +410,30 @@ RegisterCommand('batterie', function(source, args)
local type = tonumber(args[1]) or math.random(1, 4)
if type < 1 or type > 4 then type = 1 end
-- Optional: Item-Name als zweites Argument
local itemName = args[2] or "firework1"
-- Spiele die Feuerzeug-Animation ab
playLighterAnimation()
-- Starte das Feuerwerk
startFireworkBattery(coords, type)
startFireworkBattery(coords, type, itemName)
end)
-- Spezieller Test-Befehl für firework3
RegisterCommand('firework3', 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
-- Spiele die Feuerzeug-Animation ab
playLighterAnimation()
-- Starte das Feuerwerk mit firework3
startFireworkBattery(coords, 3, "firework3")
end)