
MTA:SA Fireworks
A downloadable fireworks resource
Download NowName your own price
This resource exposes two functions via the export system. Call them from any other resource using exports.firework:functionName(...).
createRocket
Spawns a firework rocket at a given position. The rocket flies upward and triggers an explosion once it reaches the target height.
Syntax
table createRocket ( float x, float y, float z, [ float targetHeight, string type, table primaryColor, table secondaryColor, float duration, float size ] )
exports.firework:createRocket ( float x, float y, float z, [ float targetHeight, string type, table primaryColor, table secondaryColor, float duration, float size ] )
Required Arguments
- x: The X world coordinate for the rocket's start position.
- y: The Y world coordinate for the rocket's start position.
- z: The Z world coordinate for the rocket's start position.
Optional Arguments
- targetHeight: Height in units relative to z at which the explosion triggers. Default:
80. - type: The explosion shape to use. See Firework Types for all available values. Default:
"sphere". - primaryColor: Main color as an RGB table, e.g.
{255, 0, 0}. Values range from0to255 or 0.0 to 1.0. If omitted, a random palette is chosen. - secondaryColor: Secondary color for two-tone effects. Same format as
primaryColor. Defaults toprimaryColorif omitted. - duration: Flight duration in seconds. Defaults to the resource's internal config value.
- size: Size multiplier for the explosion. Default:
1.0.
Example
-- Launch a red heart-shaped rocket at the local player's position
local x, y, z = getElementPosition(localPlayer)
exports.firework:createRocket({
x = x, y = y, z = z,
targetHeight = 100,
type = "heart",
primaryColor = {255, 0, 0}, -- or {1, 0, 0}
secondaryColor = {255, 255, 0}, -- or {1, 1, 0}
size = 1.2
})
createFirework
Triggers a firework explosion directly at a given position without any rocket flight.
Syntax
exports.firework:createFirework ( float x, float y, float z, [ string type, table primaryColor, table secondaryColor, int numRays, float speed, float gravity, float duration, float size ] )
Required Arguments
- x: The X world coordinate of the explosion.
- y: The Y world coordinate of the explosion.
- z: The Z world coordinate of the explosion.
Optional Arguments
- type: The explosion shape to use. See Firework Types for all available values. Default:
"sphere". - primaryColor: Main color as an RGB table, e.g.
{51, 153, 255}. Values range from0to255 or 0.0 to 1.0. If omitted, a random palette is chosen. - secondaryColor: Secondary color for two-tone effects. Defaults to
primaryColorif omitted. - numRays: Number of rays or particles emitted. Defaults to the type's built-in value.
- speed: Expansion speed of the explosion. Defaults to the type's built-in value.
- gravity: Gravitational pull applied to particles. Defaults to the type's built-in value.
- duration: Display duration in seconds. Defaults to the type's built-in value.
- size: Size multiplier for the explosion. Default:
1.0.
Example
-- Trigger a blue chrysanthemum burst at a fixed world position
exports.firework:createFirework({
x = 500, y = 500, z = 120,
type = "chrysanthemum",
primaryColor = {51, 153, 255},
size = 1.5
})
Firework Types
The type parameter accepts the following string values:
Classic shapes
spherechrysanthemumwillowpalmringdahliacrossettekamuropeonyspidercometbrocadestrobedouble
Special shapes
heartstarmaltesecruciformavengers
Algebraic curves
These types are rendered using classical mathematical curve equations. See mathworld.wolfram.com for formula references.
astroidlemniscatecardioidbutterflyrosetrifoliumquadrifoliumspirographdeltoidnephroidepicycloidhypocycloidlissajouseightspiral
Download
Download NowName your own price
Click download now to get access to the following files:
Fireworks 227 kB

Leave a comment
Log in with itch.io to leave a comment.