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