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

@ -343,8 +343,8 @@ Config.FuelConsumptionPerClass = {
[14] = 1.0, -- Boats [14] = 1.0, -- Boats
[15] = 2.0, -- Helicopters [15] = 2.0, -- Helicopters
[16] = 2.0, -- Planes [16] = 2.0, -- Planes
[17] = 1.0, -- Service [17] = 0.8, -- Service
[18] = 1.0, -- Emergency [18] = 0.6, -- Emergency
[19] = 2.0, -- Military [19] = 2.0, -- Military
[20] = 2.2, -- Commercial [20] = 2.2, -- Commercial
[21] = 3.0, -- Trains [21] = 3.0, -- Trains

View file

@ -2,12 +2,12 @@ local QBCore = exports['qb-core']:GetCoreObject()
local fireworkTime = 0 local fireworkTime = 0
local fireworkLoc = nil local fireworkLoc = nil
-- Modelle für Feuerwerks-Batterien -- Modelle für Feuerwerks-Batterien und Raketen
local batteryModels = { local fireworkModels = {
"ind_prop_firework_04", -- Standard-Feuerwerks-Batterie ["firework1"] = "ind_prop_firework_01", -- Rakete für firework1
"ind_prop_firework_03", -- Größere Feuerwerks-Batterie ["firework2"] = "ind_prop_firework_04", -- Standard-Batterie für firework2
"prop_firework_03", -- Weitere Batterie-Option ["firework3"] = "ind_prop_firework_03", -- Große Batterie für firework3
"ind_prop_firework_03" -- Große Batterie für firework3 ["firework4"] = "prop_firework_03" -- Alternative Batterie für firework4
} }
-- Verbesserte Feuerwerkseffekte ohne Flammen -- Verbesserte Feuerwerkseffekte ohne Flammen
@ -28,22 +28,145 @@ local fireworkEffects = {
"scr_indep_firework_trail_spawn" "scr_indep_firework_trail_spawn"
} }
-- Funktion zum Starten einer Feuerwerks-Batterie ohne Flammeneffekte -- Funktion zum Starten einer Feuerwerksrakete
local function startFireworkBattery(coords, type, itemName) local function launchFireworkRocket(coords)
-- Wähle ein Batteriemodell basierend auf dem Item oder Typ -- Lade das Raketenmodell
local batteryModel = "ind_prop_firework_04" -- Standard local rocketModel = "ind_prop_firework_01"
RequestModel(GetHashKey(rocketModel))
-- Spezielle Batterie für firework3 while not HasModelLoaded(GetHashKey(rocketModel)) do
if itemName == "firework3" then Wait(10)
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 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) print("Verwende Batteriemodell: " .. batteryModel)
-- Lade das Modell -- Lade das Modell
@ -77,7 +200,6 @@ local function startFireworkBattery(coords, type, itemName)
while not HasNamedPtfxAssetLoaded(asset) do while not HasNamedPtfxAssetLoaded(asset) do
Wait(10) Wait(10)
end end
print("Asset geladen: " .. asset)
end end
-- Füge einen Zündungseffekt hinzu (kleiner Funke statt Flamme) -- Füge einen Zündungseffekt hinzu (kleiner Funke statt Flamme)
@ -94,19 +216,15 @@ local function startFireworkBattery(coords, type, itemName)
-- Stoppe den Zündungseffekt -- Stoppe den Zündungseffekt
StopParticleFxLooped(ignitionEffect, 0) 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 local numShots = 15 -- Standard
if itemName == "firework3" then if itemName == "firework3" then
numShots = 30 -- Mehr Schüsse für firework3 numShots = 30 -- Mehr Schüsse für firework3 (große Batterie)
elseif type == 1 then elseif itemName == "firework2" then
numShots = math.random(10, 15) numShots = 15 -- Standard für firework2
elseif type == 2 then elseif itemName == "firework4" then
numShots = math.random(15, 20) numShots = 20 -- Etwas mehr für firework4
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")
@ -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 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)
-- Wähle ein zufälliges Asset für diesen Schuss
local selectedAsset = ptfxAssets[math.random(1, #ptfxAssets)]
-- Starteffekt (kleiner Funke statt Flamme) -- Starteffekt (kleiner Funke statt Flamme)
UseParticleFxAssetNextCall("scr_indep_fireworks") UseParticleFxAssetNextCall("scr_indep_fireworks")
StartParticleFxNonLoopedAtCoord("scr_indep_firework_sparkle_spawn", StartParticleFxNonLoopedAtCoord("scr_indep_firework_sparkle_spawn",
@ -298,20 +413,17 @@ local function startFirework(asset, coords, itemName)
fireworkTime = fireworkTime - 1 fireworkTime = fireworkTime - 1
end end
print("Countdown beendet, starte Feuerwerks-Batterie") print("Countdown beendet, starte Feuerwerk: " .. itemName)
-- Bestimme den Batterietyp basierend auf dem Asset -- Wähle die richtige Feuerwerksart basierend auf dem Item
local batteryType = 1 -- Standard if itemName == "firework1" then
if asset == "proj_xmas_firework" then -- Rakete für firework1
batteryType = 2 launchFireworkRocket(coords)
elseif asset == "scr_indep_fireworks" then else
batteryType = 3 -- Batterie für alle anderen
elseif asset == "proj_indep_firework_v2" then startFireworkBattery(coords, itemName)
batteryType = 4
end end
startFireworkBattery(coords, batteryType, itemName)
fireworkLoc = nil fireworkLoc = nil
end) end)
end end
@ -395,8 +507,8 @@ RegisterNetEvent('fireworks:client:UseFirework', function(itemName, assetName)
end) end)
end) end)
-- Test-Befehl zum direkten Auslösen von Feuerwerk -- Test-Befehl für verschiedene Feuerwerkstypen
RegisterCommand('batterie', function(source, args) RegisterCommand('feuerwerk', function(source, args)
local playerPed = PlayerPedId() local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed) local coords = GetEntityCoords(playerPed)
@ -406,22 +518,22 @@ RegisterCommand('batterie', function(source, args)
return return
end end
-- Optional: Typ der Batterie als Argument -- Item-Name als Argument
local type = tonumber(args[1]) or math.random(1, 4) local itemName = args[1] or "firework1"
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 passende Feuerwerk
startFireworkBattery(coords, type, itemName) if itemName == "firework1" then
launchFireworkRocket(coords)
else
startFireworkBattery(coords, itemName)
end
end) end)
-- Spezieller Test-Befehl für firework3 -- Spezielle Test-Befehle für die verschiedenen Feuerwerkstypen
RegisterCommand('firework3', function() RegisterCommand('rakete', function()
local playerPed = PlayerPedId() local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed) local coords = GetEntityCoords(playerPed)
@ -434,6 +546,40 @@ RegisterCommand('firework3', function()
-- Spiele die Feuerzeug-Animation ab -- Spiele die Feuerzeug-Animation ab
playLighterAnimation() playLighterAnimation()
-- Starte das Feuerwerk mit firework3 -- Starte die Rakete (firework1)
startFireworkBattery(coords, 3, "firework3") 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) end)