1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-07-02 16:51:27 +02:00
parent 837125a876
commit fc685aced9
2 changed files with 207 additions and 61 deletions

View file

@ -2,12 +2,12 @@ local QBCore = exports['qb-core']:GetCoreObject()
local fireworkTime = 0
local fireworkLoc = nil
-- Modelle für Feuerwerks-Batterien
local batteryModels = {
"ind_prop_firework_04", -- Standard-Feuerwerks-Batterie
"ind_prop_firework_03", -- Größere Feuerwerks-Batterie
"prop_firework_03", -- Weitere Batterie-Option
"ind_prop_firework_03" -- Große Batterie für firework3
-- 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
}
-- Verbesserte Feuerwerkseffekte ohne Flammen
@ -28,22 +28,145 @@ local fireworkEffects = {
"scr_indep_firework_trail_spawn"
}
-- 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"
-- 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
-- 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
end
-- 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))
}
-- 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
print("Verwende Batteriemodell: " .. batteryModel)
-- Lade das Modell
@ -77,7 +200,6 @@ local function startFireworkBattery(coords, type, itemName)
while not HasNamedPtfxAssetLoaded(asset) do
Wait(10)
end
print("Asset geladen: " .. asset)
end
-- Füge einen Zündungseffekt hinzu (kleiner Funke statt Flamme)
@ -94,19 +216,15 @@ local function startFireworkBattery(coords, type, itemName)
-- Stoppe den Zündungseffekt
StopParticleFxLooped(ignitionEffect, 0)
-- Bestimme die Anzahl der Schüsse basierend auf dem Typ oder Item
-- Bestimme die Anzahl der Schüsse basierend auf dem 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)
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
end
print("Starte Feuerwerks-Batterie mit " .. numShots .. " Schüssen")
@ -118,9 +236,6 @@ local function startFireworkBattery(coords, type, itemName)
local offsetX = math.random(-10, 10) * (i / numShots) -- Größere Streuung bei späteren Schüssen
local offsetY = math.random(-10, 10) * (i / numShots)
-- 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",
@ -298,20 +413,17 @@ local function startFirework(asset, coords, itemName)
fireworkTime = fireworkTime - 1
end
print("Countdown beendet, starte Feuerwerks-Batterie")
print("Countdown beendet, starte Feuerwerk: " .. itemName)
-- Bestimme den Batterietyp basierend auf dem Asset
local batteryType = 1 -- Standard
if asset == "proj_xmas_firework" then
batteryType = 2
elseif asset == "scr_indep_fireworks" then
batteryType = 3
elseif asset == "proj_indep_firework_v2" then
batteryType = 4
-- 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)
end
startFireworkBattery(coords, batteryType, itemName)
fireworkLoc = nil
end)
end
@ -395,8 +507,8 @@ RegisterNetEvent('fireworks:client:UseFirework', function(itemName, assetName)
end)
end)
-- Test-Befehl zum direkten Auslösen von Feuerwerk
RegisterCommand('batterie', function(source, args)
-- Test-Befehl für verschiedene Feuerwerkstypen
RegisterCommand('feuerwerk', function(source, args)
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
@ -406,22 +518,22 @@ RegisterCommand('batterie', function(source, args)
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
-- Optional: Item-Name als zweites Argument
local itemName = args[2] or "firework1"
-- Item-Name als Argument
local itemName = args[1] or "firework1"
-- Spiele die Feuerzeug-Animation ab
playLighterAnimation()
-- Starte das Feuerwerk
startFireworkBattery(coords, type, itemName)
-- Starte das passende Feuerwerk
if itemName == "firework1" then
launchFireworkRocket(coords)
else
startFireworkBattery(coords, itemName)
end
end)
-- Spezieller Test-Befehl für firework3
RegisterCommand('firework3', function()
-- Spezielle Test-Befehle für die verschiedenen Feuerwerkstypen
RegisterCommand('rakete', function()
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
@ -434,6 +546,40 @@ RegisterCommand('firework3', function()
-- Spiele die Feuerzeug-Animation ab
playLighterAnimation()
-- Starte das Feuerwerk mit firework3
startFireworkBattery(coords, 3, "firework3")
-- 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
-- Spiele die Feuerzeug-Animation ab
playLighterAnimation()
-- Starte die Standard-Batterie (firework2)
startFireworkBattery(coords, "firework2")
end)
RegisterCommand('grossebatterie', 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 die große Batterie (firework3)
startFireworkBattery(coords, "firework3")
end)