forked from Simnation/Main
edit
This commit is contained in:
parent
171b571a37
commit
f5a079935a
2 changed files with 126 additions and 75 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
-- No need for explicit import as we're using shared_scripts in fxmanifest.lua
|
||||||
|
|
||||||
local function DrawText3D(coords, text)
|
local function DrawText3D(coords, text)
|
||||||
local camCoords = GetFinalRenderedCamCoord()
|
local camCoords = GetFinalRenderedCamCoord()
|
||||||
local distance = #(coords - camCoords)
|
local distance = #(coords - camCoords)
|
||||||
|
@ -25,87 +27,133 @@ local function reqAnimDict(dict)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function reqParticle(dict)
|
local function reqParticle(dict)
|
||||||
RequestNamedPtfxAsset(dict)
|
RequestNamedPtfxAsset(dict)
|
||||||
while not HasNamedPtfxAssetLoaded(dict) do
|
while not HasNamedPtfxAssetLoaded(dict) do
|
||||||
Wait(1)
|
Wait(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Add this function to handle rocket flight
|
||||||
|
local function launchRocket(rocketObj, targetHeight, speed)
|
||||||
|
local startCoords = GetEntityCoords(rocketObj)
|
||||||
|
local targetCoords = vector3(startCoords.x, startCoords.y, startCoords.z + targetHeight)
|
||||||
|
|
||||||
|
-- Add rocket launch particle effect
|
||||||
|
UseParticleFxAsset("core")
|
||||||
|
local effect = StartParticleFxLoopedOnEntity("ent_sht_flame", rocketObj, 0.0, 0.0, -0.2, 0.0, 0.0, 0.0, 0.5, false, false, false)
|
||||||
|
|
||||||
|
-- Add rocket sound
|
||||||
|
PlaySoundFromEntity(-1, "Jet_Explosions", rocketObj, "exile_1", true, 0)
|
||||||
|
|
||||||
|
-- Make rocket fly upward
|
||||||
|
local distance = #(targetCoords - startCoords)
|
||||||
|
local steps = math.floor(distance / speed)
|
||||||
|
local stepVector = (targetCoords - startCoords) / steps
|
||||||
|
|
||||||
|
FreezeEntityPosition(rocketObj, false)
|
||||||
|
|
||||||
|
for i = 1, steps do
|
||||||
|
local newPos = startCoords + (stepVector * i)
|
||||||
|
SetEntityCoords(rocketObj, newPos.x, newPos.y, newPos.z, false, false, false, false)
|
||||||
|
Wait(10)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Stop particle effect
|
||||||
|
StopParticleFxLooped(effect, 0)
|
||||||
|
|
||||||
|
return targetCoords
|
||||||
|
end
|
||||||
|
|
||||||
for k, v in pairs(Config.Fireworks) do
|
for k, v in pairs(Config.Fireworks) do
|
||||||
if v.command then
|
if v.command then
|
||||||
RegisterCommand(v.command, function(source, args, rawCommand)
|
RegisterCommand(v.command, function(source, args, rawCommand)
|
||||||
TriggerEvent('vms_firework:startFirework', k)
|
TriggerEvent('vms_firework:startFirework', k)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local hasBox = nil
|
local hasBox = nil
|
||||||
RegisterNetEvent('vms_firework:startFirework', function(type)
|
RegisterNetEvent('vms_firework:startFirework', function(type)
|
||||||
if Config.DisableMultiplyFireworks then
|
if Config.DisableMultiplyFireworks then
|
||||||
if hasBox then
|
if hasBox then
|
||||||
return Config.Notification(Config.Translate['CANNOT_START'], 4500, 'error')
|
return Config.Notification(Config.Translate['CANNOT_START'], 4500, 'error')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if Config.Fireworks[type] then
|
if Config.Fireworks[type] then
|
||||||
local myFirework = Config.Fireworks[type]
|
local myFirework = Config.Fireworks[type]
|
||||||
local myPed = PlayerPedId()
|
local myPed = PlayerPedId()
|
||||||
local myOffset = GetOffsetFromEntityInWorldCoords(myPed, 0, .6, 0)
|
local myOffset = GetOffsetFromEntityInWorldCoords(myPed, 0, .6, 0)
|
||||||
local fireworkShoots = myFirework.shoots
|
local fireworkShoots = myFirework.shoots
|
||||||
local secondsToStart = myFirework.timeToStart
|
local secondsToStart = myFirework.timeToStart
|
||||||
reqAnimDict(Config.PlacingAnimation[1])
|
reqAnimDict(Config.PlacingAnimation[1])
|
||||||
TaskPlayAnim(myPed, Config.PlacingAnimation[1], Config.PlacingAnimation[2], -1, -8.0, 3000, 0, 0, false, false, false)
|
TaskPlayAnim(myPed, Config.PlacingAnimation[1], Config.PlacingAnimation[2], -1, -8.0, 3000, 0, 0, false, false, false)
|
||||||
Citizen.Wait((GetAnimDuration(Config.PlacingAnimation[1], Config.PlacingAnimation[2]) * 1000) - 2050)
|
Citizen.Wait((GetAnimDuration(Config.PlacingAnimation[1], Config.PlacingAnimation[2]) * 1000) - 2050)
|
||||||
hasBox = CreateObject(myFirework.prop, myOffset.x, myOffset.y, myOffset.z, true, false, false)
|
hasBox = CreateObject(myFirework.prop, myOffset.x, myOffset.y, myOffset.z, true, false, false)
|
||||||
PlaceObjectOnGroundProperly(hasBox)
|
PlaceObjectOnGroundProperly(hasBox)
|
||||||
FreezeEntityPosition(hasBox, true)
|
FreezeEntityPosition(hasBox, true)
|
||||||
Config.Notification(Config.Translate['YOU_PLACE_FIREWORK'], 4500, 'success')
|
Config.Notification(Config.Translate['YOU_PLACE_FIREWORK'], 4500, 'success')
|
||||||
local boxCoords = GetEntityCoords(hasBox)
|
local boxCoords = GetEntityCoords(hasBox)
|
||||||
while secondsToStart > 0 do
|
|
||||||
secondsToStart = secondsToStart - 5
|
|
||||||
if Config.Enable3DText then
|
|
||||||
DrawText3D(boxCoords, secondsToStart/1000)
|
|
||||||
end
|
|
||||||
Citizen.Wait(0)
|
|
||||||
end
|
|
||||||
|
|
||||||
for k, v in pairs(myFirework.particles) do
|
-- Countdown display
|
||||||
reqParticle(v.name)
|
while secondsToStart > 0 do
|
||||||
end
|
secondsToStart = secondsToStart - 5
|
||||||
|
if Config.Enable3DText then
|
||||||
|
DrawText3D(boxCoords, secondsToStart/1000)
|
||||||
|
end
|
||||||
|
Citizen.Wait(0)
|
||||||
|
end
|
||||||
|
|
||||||
while fireworkShoots ~= 0 do
|
-- Handle rocket launch for firework type 1
|
||||||
fireworkShoots = fireworkShoots - 1
|
local particleOrigin = boxCoords
|
||||||
for k, v in pairs(myFirework.particles) do
|
if myFirework.isRocket then
|
||||||
UseParticleFxAsset(v.name)
|
-- Launch the rocket
|
||||||
local effect = StartNetworkedParticleFxNonLoopedAtCoord(
|
particleOrigin = launchRocket(hasBox, myFirework.rocketHeight, myFirework.rocketSpeed)
|
||||||
v.effect,
|
|
||||||
boxCoords.x + (v.randomizeXY == true and math.random(-10, 10) or 0.0),
|
-- Wait a moment before explosion
|
||||||
boxCoords.y + (v.randomizeXY == true and math.random(-10, 10) or 0.0),
|
Citizen.Wait(500)
|
||||||
boxCoords.z + v.plusHeight,
|
end
|
||||||
0.0,
|
|
||||||
0.0,
|
-- Load particle effects
|
||||||
0.0,
|
for k, v in pairs(myFirework.particles) do
|
||||||
v.scale,
|
reqParticle(v.name)
|
||||||
false,
|
end
|
||||||
false,
|
|
||||||
false
|
-- Create firework effects
|
||||||
)
|
while fireworkShoots ~= 0 do
|
||||||
if Config.Debug then
|
fireworkShoots = fireworkShoots - 1
|
||||||
print('[ Shoots left: '..fireworkShoots..' ]', "ID: "..k, v.name, v.effect)
|
for k, v in pairs(myFirework.particles) do
|
||||||
end
|
UseParticleFxAsset(v.name)
|
||||||
Citizen.Wait(v.timeToNextShoot)
|
local effect = StartNetworkedParticleFxNonLoopedAtCoord(
|
||||||
end
|
v.effect,
|
||||||
Citizen.Wait(myFirework.timeBetweenShoots or 300)
|
particleOrigin.x + (v.randomizeXY == true and math.random(-10, 10) or 0.0),
|
||||||
end
|
particleOrigin.y + (v.randomizeXY == true and math.random(-10, 10) or 0.0),
|
||||||
NetworkFadeOutEntity(hasBox, true, false)
|
particleOrigin.z + (myFirework.isRocket and 0 or v.plusHeight),
|
||||||
if Config.Debug then
|
0.0,
|
||||||
print('Prop is removed')
|
0.0,
|
||||||
end
|
0.0,
|
||||||
Citizen.Wait(5000)
|
v.scale,
|
||||||
DeleteEntity(hasBox)
|
false,
|
||||||
hasBox = nil
|
false,
|
||||||
end
|
false
|
||||||
|
)
|
||||||
|
if Config.Debug then
|
||||||
|
print('[ Shoots left: '..fireworkShoots..' ]', "ID: "..k, v.name, v.effect)
|
||||||
|
end
|
||||||
|
Citizen.Wait(v.timeToNextShoot)
|
||||||
|
end
|
||||||
|
Citizen.Wait(myFirework.timeBetweenShoots or 300)
|
||||||
|
end
|
||||||
|
|
||||||
|
NetworkFadeOutEntity(hasBox, true, false)
|
||||||
|
if Config.Debug then
|
||||||
|
print('Prop is removed')
|
||||||
|
end
|
||||||
|
Citizen.Wait(5000)
|
||||||
|
DeleteEntity(hasBox)
|
||||||
|
hasBox = nil
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('vms_firework:notification', function(message, time, type)
|
RegisterNetEvent('vms_firework:notification', function(message, time, type)
|
||||||
Config.Notification(Config.Translate[message], time, type)
|
Config.Notification(Config.Translate[message], time, type)
|
||||||
end)
|
end)
|
|
@ -51,12 +51,15 @@ Config.LighterItem = 'lighter' -- Changed from 'bread' to 'lighter'
|
||||||
|
|
||||||
Config.Fireworks = {
|
Config.Fireworks = {
|
||||||
[1] = {
|
[1] = {
|
||||||
item = 'firework1',
|
item = 'firework_1',
|
||||||
itemRemovable = true,
|
itemRemovable = true,
|
||||||
command = nil, -- Removed command to only use items
|
command = nil,
|
||||||
shoots = 50,
|
shoots = 10,
|
||||||
prop = "ind_prop_firework_03",
|
prop = "ind_prop_firework_01", -- Changed to rocket prop
|
||||||
timeToStart = 5500,
|
isRocket = true, -- Add this flag to identify it as a flying rocket
|
||||||
|
rocketHeight = 50.0, -- How high the rocket should fly
|
||||||
|
rocketSpeed = 0.5, -- Speed of rocket ascent (lower is faster)
|
||||||
|
timeToStart = 2000, -- Reduced time to start for better experience
|
||||||
timeBetweenShoots = 1250,
|
timeBetweenShoots = 1250,
|
||||||
particles = {
|
particles = {
|
||||||
{name = "scr_indep_fireworks", effect = "scr_indep_firework_starburst", scale = 2.0, plusHeight = 50.0, randomizeXY = true, timeToNextShoot = 120},
|
{name = "scr_indep_fireworks", effect = "scr_indep_firework_starburst", scale = 2.0, plusHeight = 50.0, randomizeXY = true, timeToNextShoot = 120},
|
||||||
|
@ -82,7 +85,7 @@ Config.Fireworks = {
|
||||||
item = 'firework3',
|
item = 'firework3',
|
||||||
itemRemovable = true,
|
itemRemovable = true,
|
||||||
command = nil, -- Removed command to only use items
|
command = nil, -- Removed command to only use items
|
||||||
shoots = 80,
|
shoots = 100,
|
||||||
prop = "ind_prop_firework_03",
|
prop = "ind_prop_firework_03",
|
||||||
timeToStart = 5500,
|
timeToStart = 5500,
|
||||||
timeBetweenShoots = 250,
|
timeBetweenShoots = 250,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue