Skip to content

Particle (tm.particle) ​

Client side only. Particle effects at a position or on an entity, with optional automatic removal.

lua
local smoke = tm.particle.create({
    dict = 'cut_trevor1',
    name = 'cs_trevor_smoking_joint',
    entity = vehicle,
    bone = 'exhaust',
    offset = vec3(0.0, 0.0, 0.3),
    scale = 1.5,
    looped = true,
    duration = 10000, -- removed after 10 seconds
})

smoke:remove() -- or let the duration do it

tm.particle.create(props) ​

The props table becomes the returned object, with id, handle and remove added. Returns nil and a reason ('asset failed to load') when the particle asset does not load within 5 seconds. Passing something that is not a table, or props without dict and name, or without coords or entity, raises an error.

PropTypeDescription
dictstringRequired. Particle asset name (for example 'core').
namestringRequired. Effect name inside the asset.
coordsvector3World position. Required when there is no entity.
entityintegerAttach to this entity.
bonestringBone name on the entity (looped effects). Ignored when the entity has no such bone.
offsetvector3Offset from the entity or bone.
scalenumberScale multiplier, default 1.0.
loopedbooleanContinuous effect. A one-shot effect needs no cleanup.
networkedbooleanPlay for other players too.
durationintegerRemoves a looped effect after this many milliseconds.
onCreatedfun(handle)Called after the effect starts. An error in it is logged and does not stop the effect.

Object ​

Field or methodDescription
idUnique id of this effect.
handleThe native effect handle.
remove()Stops a looped effect and forgets it. Safe to call more than once, and after duration already removed it.

Cleanup ​

Looped effects still running when the resource stops are stopped automatically.