1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-07-02 16:34:41 +02:00
parent 24a9bd77ac
commit dacaa0d819
2 changed files with 199 additions and 103 deletions

View file

@ -2,12 +2,12 @@ local QBCore = exports['qb-core']:GetCoreObject()
local fireworkTime = 0
local fireworkLoc = nil
-- Liste der verfügbaren Feuerwerksraketen-Modelle
local fireworkProps = {
"ind_prop_firework_01", -- Standard-Feuerwerksrakete
"ind_prop_firework_02", -- Mittlere Feuerwerksrakete
"ind_prop_firework_03", -- Große Feuerwerksrakete
"ind_prop_firework_04" -- Feuerwerksraketen-Batterie
-- Modelle für Feuerwerks-Batterien
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
}
-- Farben für die Feuerwerkseffekte
@ -21,28 +21,27 @@ local colors = {
{r = 255, g = 255, b = 255} -- Weiß
}
-- Verbesserte Feuerwerk-Funktion mit sichtbaren Raketen
local function launchFirework(coords, type)
-- Wähle ein Feuerwerksmodell basierend auf dem Typ oder zufällig
local propModel = fireworkProps[type or math.random(1, #fireworkProps)]
local pedCoords = coords
-- 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)]
-- Lade das Modell
RequestModel(GetHashKey(propModel))
while not HasModelLoaded(GetHashKey(propModel)) do
RequestModel(GetHashKey(batteryModel))
while not HasModelLoaded(GetHashKey(batteryModel)) do
Wait(10)
end
-- Erstelle die sichtbare Feuerwerksrakete
local prop = CreateObject(GetHashKey(propModel),
pedCoords.x, pedCoords.y, pedCoords.z,
-- Erstelle die Batterie
local battery = CreateObject(GetHashKey(batteryModel),
coords.x, coords.y, coords.z - 0.5, -- Leicht in den Boden eingelassen
true, true, false)
-- Stelle sicher, dass die Rakete aufrecht steht
PlaceObjectOnGroundProperly(prop)
FreezeEntityPosition(prop, true)
-- Stelle die Batterie richtig auf den Boden
PlaceObjectOnGroundProperly(battery)
FreezeEntityPosition(battery, true)
-- Warte kurz, damit die Rakete sichtbar ist
-- Warte kurz, damit die Batterie sichtbar ist
Wait(500)
-- Füge einen Zündungseffekt hinzu
@ -53,92 +52,140 @@ local function launchFirework(coords, type)
UseParticleFxAssetNextCall("core")
local ignitionEffect = StartParticleFxLoopedOnEntity("ent_amb_torch_fire",
prop, 0.0, 0.0, 0.0, 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
PlaySoundFromEntity(-1, "DISTANT_FIREWORK_LAUNCH_01", prop, "dlc_sum20_beach_party_sounds", true, 20)
PlaySoundFromEntity(-1, "DISTANT_FIREWORK_LAUNCH_01", battery, "dlc_sum20_beach_party_sounds", true, 20)
-- Warte kurz für den Zündungseffekt
Wait(1000)
-- Starte den Aufstiegseffekt
UseParticleFxAssetNextCall("core")
local upEffect = StartParticleFxLoopedOnEntity("ent_dst_gen_firework",
prop, 0.0, 0.0, 0.2, 0.0, 0.0, 0.0, 1.0, false, false, false)
-- Stoppe den Zündungseffekt
StopParticleFxLooped(ignitionEffect, 0)
-- Bewege die Rakete nach oben
local startTime = GetGameTimer()
local duration = 2500 -- 2.5 Sekunden Aufstieg
local height = math.random(30, 50)
local startZ = GetEntityCoords(prop).z
-- Aufstiegsschleife
while GetGameTimer() - startTime < duration do
local progress = (GetGameTimer() - startTime) / duration
local newZ = startZ + (height * progress)
SetEntityCoords(prop, pedCoords.x, pedCoords.y, newZ)
Wait(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)
end
-- Stoppe den Aufstiegseffekt
StopParticleFxLooped(upEffect, 0)
print("Starte Feuerwerks-Batterie mit " .. numShots .. " Schüssen")
-- Verstecke die Rakete
SetEntityVisible(prop, false, 0)
-- Wähle eine zufällige Farbe
local color = colors[math.random(1, #colors)]
-- Hauptexplosion
AddExplosion(
pedCoords.x, pedCoords.y, startZ + height,
38, -- EXPLOSION_FIREWORK
1.0, -- Schaden
true, -- isAudible
false, -- isInvisible
0.0 -- Kamera-Shake
)
-- Füge mehrere Partikeleffekte für ein spektakuläres Feuerwerk hinzu
for i = 1, 5 do
-- Zufällige Positionen um den Explosionspunkt
local offsetX = math.random(-8, 8)
local offsetY = math.random(-8, 8)
local offsetZ = math.random(-4, 4)
-- Verschiedene Explosionseffekte
local effects = {
"exp_grd_grenade",
"exp_air_molotov",
"exp_grd_petrol_pump",
"exp_grd_flare"
-- 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
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)
-- Starteffekt (Abschuss von der Batterie)
UseParticleFxAssetNextCall("core")
StartParticleFxNonLoopedAtCoord("ent_sht_flame",
coords.x, coords.y, coords.z + 0.5,
0.0, 0.0, 0.0,
0.8, false, false, false)
-- 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
-- Wähle einen zufälligen Effekt
local effect = fireworkEffects[math.random(1, #fireworkEffects)]
-- Starte den Haupteffekt
UseParticleFxAssetNextCall("core")
StartParticleFxNonLoopedAtCoord(
effects[math.random(1, #effects)],
pedCoords.x + offsetX,
pedCoords.y + offsetY,
startZ + height + offsetZ,
effect,
coords.x + offsetX, coords.y + offsetY, explosionHeight,
0.0, 0.0, 0.0,
math.random(15, 25) / 10, -- Zufällige Skalierung
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),
pedCoords.x + offsetX, pedCoords.y + offsetY, startZ + height + offsetZ,
"dlc_sum20_beach_party_sounds", true, 50, false)
-- Füge zusätzliche Effekte für mehr Volumen hinzu
for j = 1, 3 do
local subOffsetX = math.random(-3, 3)
local subOffsetY = math.random(-3, 3)
local subOffsetZ = math.random(-3, 3)
Wait(math.random(100, 300))
UseParticleFxAssetNextCall("core")
StartParticleFxNonLoopedAtCoord(
fireworkEffects[math.random(1, #fireworkEffects)],
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
-- Lösche die Rakete nach einer Weile
-- Explosionsgeräusch
PlaySoundFromCoord(-1, "DISTANT_FIREWORK_BURST_0" .. math.random(1, 3),
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)
UseParticleFxAssetNextCall("core")
StartParticleFxNonLoopedAtCoord(
fireworkEffects[math.random(1, #fireworkEffects)],
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,
"dlc_sum20_beach_party_sounds", true, 50, false)
Wait(100)
end
-- Lösche die Batterie nach einer Weile
Wait(5000)
DeleteEntity(prop)
DeleteEntity(battery)
end
local function DrawText3D(x, y, z, text)
@ -180,41 +227,75 @@ local function startFirework(asset, coords)
fireworkTime = fireworkTime - 1
end
print("Countdown beendet, starte spektakuläres Feuerwerk")
print("Countdown beendet, starte Feuerwerks-Batterie")
-- Bestimme den Feuerwerkstyp basierend auf dem Asset
local fireworkType = 1 -- Standard
-- Bestimme den Batterietyp basierend auf dem Asset
local batteryType = 1 -- Standard
if asset == "proj_xmas_firework" then
fireworkType = 2
batteryType = 2
elseif asset == "scr_indep_fireworks" then
fireworkType = 3
batteryType = 3
elseif asset == "proj_indep_firework_v2" then
fireworkType = 4
batteryType = 4
end
-- Starte mehrere Feuerwerke nacheinander
local numFireworks = math.random(3, 6)
for i = 1, numFireworks do
-- Leichte Variation in der Position
local offsetX = math.random(-3, 3)
local offsetY = math.random(-3, 3)
local newCoords = {
x = coords.x + offsetX,
y = coords.y + offsetY,
z = coords.z
}
launchFirework(newCoords, fireworkType)
Wait(math.random(800, 1500)) -- Warte zwischen den Feuerwerken
end
startFireworkBattery(coords, batteryType)
fireworkLoc = nil
end)
end
-- 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)
-- Füge einen Flammeneffekt hinzu
RequestNamedPtfxAsset("core")
while not HasNamedPtfxAssetLoaded("core") 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)
-- 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)
DeleteEntity(lighter)
end
-- Überprüfe, ob der Spieler ein Feuerzeug hat
local function hasLighter()
local hasItem = QBCore.Functions.HasItem("lighter")
return hasItem
end
RegisterNetEvent('fireworks:client:UseFirework', function(itemName, assetName)
print("Feuerwerk-Event ausgelöst mit Item: " .. itemName)
-- Überprüfe zuerst, ob der Spieler ein Feuerzeug hat
if not hasLighter() then
QBCore.Functions.Notify(Lang:t('firework.no_lighter'), 'error')
return
end
QBCore.Functions.Progressbar('spawn_object', Lang:t('firework.place_progress'), 3000, false, true, {
disableMovement = true,
disableCarMovement = true,
@ -230,8 +311,12 @@ RegisterNetEvent('fireworks:client:UseFirework', function(itemName, assetName)
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)
print("Feuerwerk platziert, beginne Anzündung")
-- Spiele die Feuerzeug-Animation ab
playLighterAnimation()
-- Starte das Feuerwerk
startFirework(assetName, pos)
end, function() -- Cancel
StopAnimTask(PlayerPedId(), 'anim@narcotics@trash', 'drop_front', 1.0)
@ -240,13 +325,23 @@ RegisterNetEvent('fireworks:client:UseFirework', function(itemName, assetName)
end)
-- Test-Befehl zum direkten Auslösen von Feuerwerk
RegisterCommand('feuerwerk', function(source, args)
RegisterCommand('batterie', function(source, args)
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
-- Optional: Typ des Feuerwerks als Argument
-- Überprüfe zuerst, ob der Spieler ein Feuerzeug hat
if not hasLighter() then
QBCore.Functions.Notify(Lang:t('firework.no_lighter'), 'error')
return
end
-- Optional: Typ der Batterie als Argument
local type = tonumber(args[1]) or math.random(1, 4)
if type < 1 or type > 4 then type = 1 end
launchFirework(coords, type)
-- Spiele die Feuerzeug-Animation ab
playLighterAnimation()
-- Starte das Feuerwerk
startFireworkBattery(coords, type)
end)

View file

@ -47,6 +47,7 @@ local Translations = {
place_progress = "Feuerwerk platzieren...",
canceled = "Abgebrochen...",
time_left = "Feuerwerk startet in ~r~"
no_lighter = 'Du brauchst ein Feuerzeug, um das Feuerwerk zu zünden!'
},
seatbelt = {
use_harness_progress = "Renngurt anlegen",