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

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
+41 -49
View File
@@ -1,61 +1,53 @@
function CreateParticleFX(dict, ptfx, pos, rot, scale, color, looped, loopLength) Particle = {}
CreateThread(function() Particles = {}
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) --- Load a particle dictionary. This function will block until the dictionary is loaded.
if looped then --- @param dict string -- The name of the particle dictionary to load.
StartParticleFxLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false) --- @return boolean -- Returns true if the dictionary was loaded successfully, false otherwise.
Wait(loopLength) --- @throws string -- Throws an error if the dictionary fails to load after 100 attempts.
RemoveParticleFxInRange(pos.x, pos.y, pos.z, 0.01) function Particle.LoadDict(dict)
else RequestNamedPtfxAsset(dict)
StartParticleFxNonLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false) local failed = 100
end while not HasNamedPtfxAssetLoaded(dict) and failed >= 0 do
RemoveNamedPtfxAsset(ptfx) failed = failed - 1
end) Wait(50)
end
assert(failed >= 0, "Failed to load particle dictionary: " .. dict)
return true
end end
function CreateParticleFXOnEntityBone(dict, ptfx, entity, bone, offset, rot, scale, color, looped, loopLength) --- Create a particle effect at the specified position and rotation.
local failed = 5 --- @param dict string
while not HasNamedPtfxAssetLoaded(dict) and failed >= 0 do --- @param ptfx string
RequestNamedPtfxAsset(ptfx) --- @param pos vector3
failed = failed - 1 --- @param rot vector3
Wait(0) --- @param scale number
end --- @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
local bleh = nil
if looped then if looped then
bleh = StartNetworkedParticleFxLoopedOnEntityBone(ptfx, entity, offset.x, offset.y, offset.z, rot.x, rot.y, rot.z, bone, scale, false, false, false) handle = StartParticleFxLoopedAtCoord(ptfx, pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, scale, false, false, false, false)
SetParticleFxLoopedColour(handle, color.x, color.y, color.z, 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)