Update particles.lua

This commit is contained in:
gononono64 committed 2025-04-20 18:54:27 -05:00
1 parent 7d43d65058
commit 86487de62d
1 file changed
+17 -7
+17 -7
View File
@@ -27,20 +27,30 @@ end
--- @return number|nil ptfxHandle -- The handle of the particle effect, or nil if it failed to create. --- @return number|nil ptfxHandle -- The handle of the particle effect, or nil if it failed to create.
function Particle.Create(dict, ptfx, pos, rot, scale, color, looped, loopLength) function Particle.Create(dict, ptfx, pos, rot, scale, color, looped, loopLength)
LoadPtfxAsset(dict) LoadPtfxAsset(dict)
CreateThread(function()
UseParticleFxAssetNextCall(dict) UseParticleFxAssetNextCall(dict)
SetParticleFxNonLoopedColour(color.x, color.y, color.z) SetParticleFxNonLoopedColour(color.x, color.y, color.z)
local particle = nil
if looped then if looped then
StartParticleFxLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false) particle = StartParticleFxLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false)
CreateThread(function()
if loopLength then if loopLength then
Wait(loopLength) Wait(loopLength)
RemoveParticleFxInRange(pos.x, pos.y, pos.z, 0.01) Particle.Remove(particle)
end end
else
StartParticleFxNonLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false)
end
RemoveNamedPtfxAsset(ptfx)
end) end)
else
particle = StartParticleFxNonLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false)
end
return particle
end
function Particle.Remove(particle)
if not particle then return end
StopParticleFxLooped(particle, false)
RemoveParticleFx(particle, false)
RemoveNamedPtfxAsset(particle)
end end
function Particle.CreateOnEntity(dict, ptfx, entity, offset, rot, scale, color, looped, loopLength) function Particle.CreateOnEntity(dict, ptfx, entity, offset, rot, scale, color, looped, loopLength)