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 ittm.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.
| Prop | Type | Description |
|---|---|---|
dict | string | Required. Particle asset name (for example 'core'). |
name | string | Required. Effect name inside the asset. |
coords | vector3 | World position. Required when there is no entity. |
entity | integer | Attach to this entity. |
bone | string | Bone name on the entity (looped effects). Ignored when the entity has no such bone. |
offset | vector3 | Offset from the entity or bone. |
scale | number | Scale multiplier, default 1.0. |
looped | boolean | Continuous effect. A one-shot effect needs no cleanup. |
networked | boolean | Play for other players too. |
duration | integer | Removes a looped effect after this many milliseconds. |
onCreated | fun(handle) | Called after the effect starts. An error in it is logged and does not stop the effect. |
Object
| Field or method | Description |
|---|---|
id | Unique id of this effect. |
handle | The 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.