- Documentation
- Shared functions
- createParticleEffect
Function
createParticleEffect
A short effect: the emitter releases particles for the given time and removes itself once the last one fades. No need to destroy it. On the server, every player nearby sees the effect.
Syntax
element createParticleEffect(float x, float y, float z, string|table settings [, float seconds = 2, table overrides = nil])Arguments
xfloat- Position X.
yfloat- Position Y.
zfloat- Position Z.
settingsstring|table- A preset name or a settings table.
secondsfloat, optional = 2- How long the emitter releases particles.
overridestable, optional = nil- Fields that replace the preset's settings.
Returns
The emitter or false.
Example
Sparks where a bullet hits.
addEventHandler("onClientPlayerWeaponFire", localPlayer, function(weapon, hx, hy, hz)
createParticleEffect(hx, hy, hz, "sparks", 0.5, { rate = 300 })
end)
addCommandHandler("show", function(player)
local x, y, z = getElementPosition(player)
createParticleEffect(x, y, z + 25, "firework")
end)
See also
createParticleEmitterCreates an emitter of moving particles simulated by the game: fire, smoke, sparks, snow, portals and anything you build from the settings. The fourth argument is a preset name or a settings table, the fifth overrides chosen fields of the preset. Returns a"particle"element that can be moved, attached and destroyed like any other. Called on the server, it creates an emitter every player sees.burstParticlesReleases the given number of particles at once, regardless ofrate: an explosion, a hit, a burst of confetti.