diff --git a/client/functions.lua b/client/functions.lua index 67919f2..a416764 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -734,3 +734,79 @@ function QBCore.Functions.SetVehicleProperties(vehicle, props) end end end + +function QBCore.Functions.LoadParticleDictionary(dictionary) + if not HasNamedPtfxAssetLoaded(dictionary) then + RequestNamedPtfxAsset(dictionary) + while not HasNamedPtfxAssetLoaded(dictionary) do + Wait(0) + end + end +end + +function QBCore.Functions.StartParticleAtCoord(Dict, ptName, looped, coords, rot, scale, alpha, color, duration) + QBCore.Functions.LoadParticleDictionary(Dict) + UseParticleFxAssetNextCall(Dict) + SetPtfxAssetNextCall(Dict) + local particleHandle + if looped then + particleHandle = StartParticleFxLoopedAtCoord(ptName, coords.x, coords.y, coords.z, rot.x, rot.y, rot.z, scale or 1.0) + if color then + SetParticleFxLoopedColour(particleHandle, color.r, color.g, color.b, false) + end + SetParticleFxLoopedAlpha(particleHandle, alpha or 10.0) + if duration then + Wait(duration) + StopParticleFxLooped(particleHandle, 0) + end + else + SetParticleFxNonLoopedAlpha(alpha or 10.0) + if color then + SetParticleFxNonLoopedColour(color.r, color.g, color.b) + end + StartParticleFxNonLoopedAtCoord(ptName, coords.x, coords.y, coords.z, rot.x, rot.y, rot.z, scale or 1.0) + end + + return particleHandle +end + +function QBCore.Functions.StartParticleOnEntity(Dict, ptName, looped, entity, bone, offset, rot, scale, alpha, color, evolution, duration) + QBCore.Functions.LoadParticleDictionary(Dict) + UseParticleFxAssetNextCall(Dict) + local particleHandle, boneID + if bone and GetEntityType(entity) == 1 then + boneID = GetPedBoneIndex(entity, bone) + elseif bone then + boneID = GetEntityBoneIndexByName(entity, bone) + end + if looped then + if bone then + particleHandle = StartParticleFxLoopedOnEntityBone(ptName, entity, offset.x, offset.y, offset.z, rot.x, rot.y, rot.z, boneID, scale) + else + particleHandle = StartParticleFxLoopedOnEntity(ptName, entity, offset.x, offset.y, offset.z, rot.x, rot.y, rot.z, scale) + end + if evolution then + SetParticleFxLoopedEvolution(particleHandle, evolution.name, evolution.amount, false) + end + if color then + SetParticleFxLoopedColour(particleHandle, color.r, color.g, color.b, false) + end + SetParticleFxLoopedAlpha(particleHandle, alpha) + if duration then + Wait(duration) + StopParticleFxLooped(particleHandle, 0) + end + else + SetParticleFxNonLoopedAlpha(alpha or 10.0) + if color then + SetParticleFxNonLoopedColour(color.r, color.g, color.b) + end + if bone then + StartParticleFxNonLoopedOnPedBone(ptName, entity, offset.x, offset.y, offset.z, rot.x, rot.y, rot.z, boneID, scale) + else + StartParticleFxNonLoopedOnEntity(ptName, entity, offset.x, offset.y, offset.z, rot.x, rot.y, rot.z, scale) + end + end + + return particleHandle +end