Browse docs

Lua exports

Place, schedule and remove fireworks from a FiveM server resource and inspect local particle statistics.

Use the server exports to control fireworks from a DJ script, event schedule or other FiveM resource. Add the dependency to the calling resource so Fireworks starts first. FiveM Lua exports

fxmanifest.lua
dependency "sky_fireworks"

Server exports

ExportSuccessBehaviour
GetFireworkCatalog()Array of entriesEach entry has preset, item, kind, label and shots. Use a returned preset or item ID when spawning.
SpawnFirework(preset, coords, options?)Article IDPlaces an unlit article. Pass a vector3 or { x, y, z } at the base of the model. Optional heading is in degrees and bucket defaults to 0.
GetFirework(id)Article tableReturns id, preset, coords, heading, bucket and status. After ignition it includes runId and startsInMs.
IgniteFirework(id, options?)Run IDSchedules one article. Optional delayMs sets its first cue offset and fuse = true plays the in-game fuse where supported.
IgniteFireworks(cues, options?)Run IDTakes an array of { id, delayMs? } entries for the same routing bucket. Equal delays start together. Optional fuse = true applies to the whole sequence.
GetFireworkShow(runId)Run tableReturns id, ids, bucket, status, startsInMs and endsInMs.
DeleteFirework(id)trueRemoves an unlit article or stops a run with a single article.
StopFireworkShow(runId)trueCancels a scheduled run or stops an active one, including every article in that run.

Article status is placed, scheduled or running. Run status is scheduled until the first cue and running until playback ends. Both IDs are strings and expire at the end of playback, on removal or when their owning resource stops. Each resource can access and control its own IDs. API placements stream to nearby players in the selected routing bucket without changing player inventories.

Delays are whole milliseconds and default to 0. The sequence can last up to 30 minutes within the playback budget. Fireworks adds a short synchronization lead. Fuses and large sequences can add more lead time. Read startsInMs from the run right after ignition to line up music or lighting with its first cue. Roman candles and Bengal flares from the catalogue play as stationary effects.

Start a timed sequence

Call this from your server-side cue handler. Supply the actual base coordinates of each article and the event's routing bucket. The two fountains start together, followed by the battery 2.5 seconds later.

server.lua
local fireworks = exports["sky_fireworks"]

local function fireDisplay(left, right, center, bucket)
    local placements = {
        { preset = "goldfountain", coords = left, delayMs = 0 },
        { preset = "silverfan", coords = right, delayMs = 0 },
        { preset = "sky_firework_signalnine", coords = center, delayMs = 2500 },
    }

    local cues = {}
    local function clearPlacements()
        for _, cue in ipairs(cues) do
            fireworks:DeleteFirework(cue.id)
        end
    end

    for _, placement in ipairs(placements) do
        local id, reason = fireworks:SpawnFirework(placement.preset, placement.coords, { bucket = bucket })
        if not id then
            clearPlacements()
            return false, reason
        end
        cues[#cues + 1] = { id = id, delayMs = placement.delayMs }
    end

    local runId, reason = fireworks:IgniteFireworks(cues)
    if not runId then clearPlacements() end
    return runId, reason
end

Handle a rejected call

An unsuccessful call returns false, reason. A rejected ignition leaves the placed articles available for retry or removal.

ErrorMeaning
invalid_caller, not_foundThe call has no owning server resource, or the ID is unknown, expired or belongs to another resource.
invalid_preset, invalid_coords, invalid_optionsUse a preset from the catalogue, valid world coordinates and supported option types.
invalid_cues, invalid_delay, duplicate_idSupply a dense array with one entry per article and a whole delay in milliseconds.
already_ignited, part_of_showThe article already belongs to a run. Use StopFireworkShow to cancel a run containing several articles.
different_bucket, different_areaA sequence needs one routing bucket and one site. Every article must be within 1,000 metres of its first listed article.
limit, busyThe placement cap or the shared playback budget was reached. Try a smaller sequence, stagger its launches or wait for current runs to finish.

particleStats()

exports["sky_fireworks"]:particleStats() takes no arguments and returns a table of numeric statistics for the local player's Fireworks renderer. Read it on demand during a show to compare distance, effect density and quality.

client.lua
local stats = exports["sky_fireworks"]:particleStats()

print(("Fireworks native handles: %d (peak %d), failed starts: %d"):format(
    stats.active, stats.native_peak, stats.native_start_failures
))
FieldsMeaning
active, active_primary, native_peakActive native handles, active primary handles and the peak active handle count.
visible_batteries, native_batteriesNearby active sources considered by the native budget, including the sources currently allocated native detail.
native_start_failures, native_backoff, native_configured_budget_limited, battery_limitedFailed native starts and skips due to backoff or budget.
native_configured_budget, native_quality, sampled_frame_msConfigured native budget, current local quality multiplier and smoothed client frame time in milliseconds.
started, removed, expired, culled, late, fallbackNative stage starts, removal and expiry, visibility or timing skips, and alternative rendering.
rise_started, rise_limited, launch_limited, burst_limited, ground_limited, fuse_limitedStage-specific counters for rise, launch, burst, ground and fuse effects.
visual_prepares, visual_limited_jobs, visual_skipped_jobs, visual_frustum_culled, visual_peak_triangles, smoke_light_samplesWorld-space render work, limits, view culling, peak triangle count and lighting samples.
show_cleanup_batches, largest_show_cleanupCleanup count and the largest cleanup batch.
timed_crackle_clouds, timed_crackle_onsets, timed_crackle_nests, timed_crackle_max_rise, timed_crackle_max_drop, timed_crackle_max_drift, timed_crackle_peak_trianglesMeasurements for timed world-space crackle effects.
relit_bouquets, brocade_segments, filtered_brocade_grains, willow_dust_prepared, willow_dust_drawnAdditional counters for authored spark, trail and dust effects.
crackle_active, crackle_started, crackle_limited, crackle_peakLegacy native crackle counters. The current renderer returns zero for these fields.

Some counters reset when the renderer starts a new playback session after its owned stages clear. Read the export during comparable shots. Its counters describe Fireworks only. Use the performance guide for shared pool and audio checks.

Record the local mix

The Fireworks audio page provides a JavaScript diagnostic helper for listening checks. Select the sky_fireworks frame in FiveM NUI Developer Tools to use this example. FiveM NUI Developer Tools

const take = await recordFireworksMix(12);
console.log(take.sampleRate, take.startFrame, take.paddedFrames, take.gaps);

The duration is in seconds and must be greater than 0 and at most 90. The Promise returns the local stereo WAV in take.wav together with the sample rate, starting frame and gap information. You can pass an optional AbortSignal as the second argument. This is a local NUI helper.