1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-07-27 05:34:17 +02:00
parent e283a1c311
commit 618987ca69
105 changed files with 1 additions and 1339 deletions

View file

@ -0,0 +1,5 @@
![FIREWORKS](https://user-images.githubusercontent.com/60104107/209708278-b9b55a71-8d64-4917-8c86-4f7002922e10.png)
# vms_firework
### https://discord.gg/k4YNwYxE4h

View file

@ -0,0 +1,159 @@
-- No need for explicit import as we're using shared_scripts in fxmanifest.lua
local function DrawText3D(coords, text)
local camCoords = GetFinalRenderedCamCoord()
local distance = #(coords - camCoords)
local scale = (0.8 / distance) * 2
local fov = (1 / GetGameplayCamFov()) * 100
scale = scale * fov
SetTextScale(0.0 * scale, 0.55 * scale)
SetTextFont(4)
SetTextProportional(1)
SetTextDropShadow()
SetTextColour(240, 240, 240, 185)
BeginTextCommandDisplayText('STRING')
SetTextCentre(true)
AddTextComponentSubstringPlayerName(text)
SetDrawOrigin(coords.xyz, 0)
EndTextCommandDisplayText(0.0, 0.0)
ClearDrawOrigin()
end
local function reqAnimDict(dict)
while not HasAnimDictLoaded(dict) do
RequestAnimDict(dict)
Wait(2)
end
end
local function reqParticle(dict)
RequestNamedPtfxAsset(dict)
while not HasNamedPtfxAssetLoaded(dict) do
Wait(1)
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
if v.command then
RegisterCommand(v.command, function(source, args, rawCommand)
TriggerEvent('vms_firework:startFirework', k)
end)
end
end
local hasBox = nil
RegisterNetEvent('vms_firework:startFirework', function(type)
if Config.DisableMultiplyFireworks then
if hasBox then
return Config.Notification(Config.Translate['CANNOT_START'], 4500, 'error')
end
end
if Config.Fireworks[type] then
local myFirework = Config.Fireworks[type]
local myPed = PlayerPedId()
local myOffset = GetOffsetFromEntityInWorldCoords(myPed, 0, .6, 0)
local fireworkShoots = myFirework.shoots
local secondsToStart = myFirework.timeToStart
reqAnimDict(Config.PlacingAnimation[1])
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)
hasBox = CreateObject(myFirework.prop, myOffset.x, myOffset.y, myOffset.z, true, false, false)
PlaceObjectOnGroundProperly(hasBox)
FreezeEntityPosition(hasBox, true)
Config.Notification(Config.Translate['YOU_PLACE_FIREWORK'], 4500, 'success')
local boxCoords = GetEntityCoords(hasBox)
-- Countdown display
while secondsToStart > 0 do
secondsToStart = secondsToStart - 5
if Config.Enable3DText then
DrawText3D(boxCoords, secondsToStart/1000)
end
Citizen.Wait(0)
end
-- Handle rocket launch for firework type 1
local particleOrigin = boxCoords
if myFirework.isRocket then
-- Launch the rocket
particleOrigin = launchRocket(hasBox, myFirework.rocketHeight, myFirework.rocketSpeed)
-- Wait a moment before explosion
Citizen.Wait(500)
end
-- Load particle effects
for k, v in pairs(myFirework.particles) do
reqParticle(v.name)
end
-- Create firework effects
while fireworkShoots ~= 0 do
fireworkShoots = fireworkShoots - 1
for k, v in pairs(myFirework.particles) do
UseParticleFxAsset(v.name)
local effect = StartNetworkedParticleFxNonLoopedAtCoord(
v.effect,
particleOrigin.x + (v.randomizeXY == true and math.random(-10, 10) or 0.0),
particleOrigin.y + (v.randomizeXY == true and math.random(-10, 10) or 0.0),
particleOrigin.z + (myFirework.isRocket and 0 or v.plusHeight),
0.0,
0.0,
0.0,
v.scale,
false,
false,
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)
RegisterNetEvent('vms_firework:notification', function(message, time, type)
Config.Notification(Config.Translate[message], time, type)
end)

View file

@ -0,0 +1,123 @@
-- Hi, if you like the script, join the discord: https://discord.gg/k4YNwYxE4h
Config = {}
Config.Debug = false
Config.Core = "QB-Core" -- "ESX" / "QB-Core"
if Config.Core == "ESX" then
ESX = exports['es_extended']:getSharedObject()
elseif Config.Core == "QB-Core" then
QBCore = exports['qb-core']:GetCoreObject()
end
-- Changed notification system to use ox_lib
Config.Notification = function(message, time, type)
if type == "success" then
lib.notify({
title = 'FIREWORK',
description = message,
duration = time,
type = 'success',
icon = 'fire'
})
elseif type == "error" then
lib.notify({
title = 'FIREWORK',
description = message,
duration = time,
type = 'error',
icon = 'fire'
})
end
end
Config.Translate = {
['CANNOT_START'] = "You can't set off several fireworks at once, wait until the current one goes off", -- Only if: Config.DisableMultiplyFireworks = true
['NEED_LIGHTER'] = "You need have lighter!", -- Only if: Config.NeedLighter = true
['YOU_PLACE_FIREWORK'] = "You place the firework!",
}
Config.Enable3DText = true -- 3DText on fireworks, shows the time to go off
Config.PlacingAnimation = {'anim@mp_fireworks', 'place_firework_3_box'} -- Animation of placing firework
Config.DisableMultiplyFireworks = false -- if you set it true, the player will be able to place one firework, the next one only after he finishes shooting
-- Enabled lighter requirement
Config.NeedLighter = true
Config.LighterItem = 'lighter' -- Changed from 'bread' to 'lighter'
Config.Fireworks = {
[1] = {
item = 'firework1',
itemRemovable = true,
command = nil,
shoots = 8,
prop = "ind_prop_firework_01", -- Changed to rocket prop
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,
particles = {
{name = "scr_indep_fireworks", effect = "scr_indep_firework_starburst", scale = 2.0, plusHeight = 50.0, randomizeXY = true, timeToNextShoot = 120},
{name = "proj_indep_firework", effect = "scr_indep_firework_grd_burst", scale = 2.0, plusHeight = 50.0, randomizeXY = true, timeToNextShoot = 300},
{name = "proj_indep_firework", effect = "scr_indep_firework_air_burst", scale = 2.0, plusHeight = 50.0, randomizeXY = true, timeToNextShoot = 600},
},
},
[2] = {
item = 'firework2',
itemRemovable = true,
command = nil, -- Removed command to only use items
shoots = 80,
prop = "ind_prop_firework_03",
timeToStart = 5500,
timeBetweenShoots = 250,
particles = {
{name = "scr_indep_fireworks", effect = "scr_indep_firework_trailburst", scale = 2.0, plusHeight = 10.0, randomizeXY = true, timeToNextShoot = 125},
{name = "proj_indep_firework_v2", effect = "scr_firework_indep_burst_rwb", scale = 1.0, plusHeight = 50.0, randomizeXY = true, timeToNextShoot = 125},
{name = "proj_xmas_firework", effect = "scr_firework_xmas_ring_burst_rgw", scale = 1.0, plusHeight = 50.0, randomizeXY = true, timeToNextShoot = 125},
},
},
[3] = {
item = 'firework3',
itemRemovable = true,
command = nil, -- Removed command to only use items
shoots = 100,
prop = "ind_prop_firework_03",
timeToStart = 5500,
timeBetweenShoots = 250,
particles = {
{name = "proj_indep_firework", effect = "scr_indep_firework_air_burst", scale = 1.0, plusHeight = 50.0, randomizeXY = true, timeToNextShoot = 125},
{name = "proj_indep_firework_v2", effect = "scr_firework_indep_spiral_burst_rwb", scale = 1.0, plusHeight = 50.0, randomizeXY = true, timeToNextShoot = 125},
{name = "proj_indep_firework_v2", effect = "scr_firework_indep_repeat_burst_rwb", scale = 1.0, plusHeight = 50.0, randomizeXY = true, timeToNextShoot = 125},
{name = "scr_indep_fireworks", effect = "scr_indep_firework_starburst", scale = 1.0, plusHeight = 50.0, randomizeXY = true, timeToNextShoot = 125},
},
},
[4] = {
item = 'firework4',
itemRemovable = true,
command = nil, -- Removed command to only use items
shoots = 50,
prop = "ind_prop_firework_03",
timeToStart = 5000,
timeBetweenShoots = 550,
particles = {
{name = "scr_indep_fireworks", effect = "scr_indep_firework_trailburst", scale = 4.0, plusHeight = 50.0, randomizeXY = true, timeToNextShoot = 10},
},
},
[5] = {
item = 'fontain4',
itemRemovable = true,
command = nil, -- Removed command to only use items
shoots = 80,
prop = "ind_prop_firework_04",
timeToStart = 3500,
timeBetweenShoots = 700,
particles = {
{name = "scr_indep_fireworks", effect = "scr_indep_firework_fountain", scale = 0.25, plusHeight = 0.25, randomizeXY = false, timeToNextShoot = 500},
},
},
}

View file

@ -0,0 +1,25 @@
fx_version 'cerulean'
game 'gta5'
lua54 'yes' -- Add this line to enable Lua 5.4
author 'Your Name'
description 'Firework Script'
version '1.0.0'
shared_scripts {
'@ox_lib/init.lua',
'config.lua'
}
client_scripts {
'client.lua'
}
server_scripts {
'server.lua'
}
dependencies {
'ox_lib'
}

View file

@ -0,0 +1,37 @@
if Config.Core == "ESX" then
for k, v in pairs(Config.Fireworks) do
if v.item then
ESX.RegisterUsableItem(v.item, function(source)
local xPlayer = ESX.GetPlayerFromId(source)
if Config.NeedLighter then
local isHaveLighter = xPlayer.getInventoryItem(Config.LighterItem).count
if isHaveLighter == 0 then
return TriggerClientEvent('vms_firework:notification', source, 'NEED_LIGHTER', 5000, 'error')
end
end
if v.itemRemovable then
xPlayer.removeInventoryItem(v.item, 1)
end
TriggerClientEvent('vms_firework:startFirework', source, k)
end)
end
end
elseif Config.Core == "QB-Core" then
for k, v in pairs(Config.Fireworks) do
if v.item then
QBCore.Functions.CreateUseableItem(v.item, function(source, item)
local Player = QBCore.Functions.GetPlayer(source)
if Config.NeedLighter then
local isHaveLighter = Player.Functions.GetItemByName(Config.LighterItem)
if isHaveLighter == nil or isHaveLighter.amount == 0 then
return TriggerClientEvent('vms_firework:notification', source, 'NEED_LIGHTER', 5000, 'error')
end
end
if v.itemRemovable then
Player.Functions.RemoveItem(v.item, 1, false)
end
TriggerClientEvent('vms_firework:startFirework', source, k)
end)
end
end
end