This commit is contained in:
MrNewb committed 2025-04-10 22:20:14 -04:00
commit 93a8e20a77
4 files changed
+56 -54

No files matched your search

+1
View File
@@ -67,6 +67,7 @@ cLib.Utility = Utility or Require("lib/utility/client/utility.lua")
cLib.PlaceableObject = PlaceableObject or Require("lib/placers/client/placeable_object.lua") cLib.PlaceableObject = PlaceableObject or Require("lib/placers/client/placeable_object.lua")
cLib.Raycast = Raycast or Require("lib/raycast/client/raycast.lua") cLib.Raycast = Raycast or Require("lib/raycast/client/raycast.lua")
cLib.Point = Point or Require("lib/points/client/points.lua") cLib.Point = Point or Require("lib/points/client/points.lua")
cLib.Particle = Particle or Require("lib/particles/client/particles.lua")
cLib.Object = Object or Require("lib/entities/client/entity_object.lua") cLib.Object = Object or Require("lib/entities/client/entity_object.lua")
return cLib return cLib
+40 -48
View File
@@ -1,61 +1,53 @@
function CreateParticleFX(dict, ptfx, pos, rot, scale, color, looped, loopLength) Particle = {}
CreateThread(function() Particles = {}
local failed = 5
--- Load a particle dictionary. This function will block until the dictionary is loaded.
--- @param dict string -- The name of the particle dictionary to load.
--- @return boolean -- Returns true if the dictionary was loaded successfully, false otherwise.
--- @throws string -- Throws an error if the dictionary fails to load after 100 attempts.
function Particle.LoadDict(dict)
RequestNamedPtfxAsset(dict)
local failed = 100
while not HasNamedPtfxAssetLoaded(dict) and failed >= 0 do while not HasNamedPtfxAssetLoaded(dict) and failed >= 0 do
RequestNamedPtfxAsset(ptfx)
failed = failed - 1 failed = failed - 1
Wait(0) Wait(50)
end
assert(failed >= 0, "Failed to load particle dictionary: " .. dict)
return true
end end
--- Create a particle effect at the specified position and rotation.
--- @param dict string
--- @param ptfx string
--- @param pos vector3
--- @param rot vector3
--- @param scale number
--- @param color vector3
--- @param looped boolean
--- @param loopLength number|nil
--- @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)
if not Particle.LoadDict(dict) then return end
UseParticleFxAssetNextCall(dict) UseParticleFxAssetNextCall(dict)
SetParticleFxNonLoopedColour(color.x, color.y, color.z) local handle = 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) handle = StartParticleFxLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false)
Wait(loopLength) SetParticleFxLoopedColour(handle, color.x, color.y, color.z, false)
RemoveParticleFxInRange(pos.x, pos.y, pos.z, 0.01)
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
function CreateParticleFXOnEntityBone(dict, ptfx, entity, bone, offset, rot, scale, color, looped, loopLength)
local failed = 5
while not HasNamedPtfxAssetLoaded(dict) and failed >= 0 do
RequestNamedPtfxAsset(ptfx)
failed = failed - 1
Wait(0)
end
UseParticleFxAssetNextCall(dict)
SetParticleFxNonLoopedColour(color.x, color.y, color.z)
local bleh = nil
if looped then
bleh = StartNetworkedParticleFxLoopedOnEntityBone(ptfx, entity, offset.x, offset.y, offset.z, rot.x, rot.y, rot.z, bone, scale, false, false, false)
if loopLength then if loopLength then
Wait(loopLength) Wait(loopLength)
RemoveParticleFxFromEntity(entity) StopParticleFxLooped(handle, 0)
RemoveParticleFx(handle, false)
end end
else else
bleh = StartNetworkedParticleFxNonLoopedOnEntityBone(ptfx, entity, offset.x, offset.y, offset.z, rot.x, rot.y, rot.z, bone, scale, false, false, false) SetParticleFxNonLoopedColour(color.x, color.y, color.z)
handle = StartParticleFxNonLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false)
RemoveParticleFx(handle, false)
end end
RemoveNamedPtfxAsset(ptfx) return handle
return bleh
end end
function PlayParticleFX(dict, name, looped, x, y, z, rotX, rotY, rotZ, scale) -- need to add looping effects (regarless of if its a looped particle or not)
RequestNamedPtfxAsset(dict)
while not HasNamedPtfxAssetLoaded(dict) do
Wait(0) return Particle
end
SetPtfxAssetNextCall(dict)
UseParticleFxAssetNextCall(dict)
local particle = nil
if looped then
particle = StartParticleFxLoopedAtCoord(name, x, y, z , rotX, rotY, rotZ, scale)
else
particle = StartParticleFxNonLoopedAtCoord(name, x, y, z, rotX, rotY, rotZ, scale, false, false, false)
end
return particle
end
+8 -6
View File
@@ -39,14 +39,16 @@ function OxToQBInput(data)
} }
if v.type == "select" then if v.type == "select" then
input.text = "" input.text = ""
input.options = { input.options = {}
{value = v.value, text = v.label} for k, j in pairs(v.options) do
} table.insert(input.options, {value = j.value, text = j.label})
end
elseif v.type == "checkbox" then elseif v.type == "checkbox" then
input.text = "" input.text = ""
input.options = { input.options = {}
{value = v.value, text = v.label} for k, j in pairs(v.options) do
} table.insert(input.options, {value = j.value, text = j.label})
end
end end
table.insert(returnData, input) table.insert(returnData, input)
end end
+7
View File
@@ -0,0 +1,7 @@
RegisterCommand("test_particle", function(source, args, rawCommand)
local playerPed = PlayerPedId()
local coords = GetOffsetFromEntityInWorldCoords(playerPed, 0.0, 1.0, 0.0)
local heading = GetEntityHeading(playerPed)
Particle.Create("core", "ent_dst_concrete_large", coords, vector3(0.0, 0.0, heading), 1.0, vector3(1.0, 1.0, 1.0), false)
end)