marker fix

wasnt drawing at the correct location just the first location.

cleaned up prints in particles
This commit is contained in:
gononono64 committed 2025-05-12 02:44:27 -05:00
1 parent b39e9afb2f
commit 340b57d301
3 files changed
+13 -73

No files matched your search

+13 -54
View File
@@ -37,7 +37,6 @@ function Marker.Create(data)
local data = {
id = _id,
position = vector3(basePosition.x + baseOffset.x, basePosition.y + baseOffset.y, basePosition.z + baseOffset.z),
offset = baseOffset,
marker = data.marker or 1,
rotation = data.rotation or vector3(0, 0, 0),
size = data.size or vector3(1.0, 1.0, 1.0),
@@ -57,7 +56,7 @@ function Marker.Create(data)
function(_)
if not Created[_id] then return point.Remove(_id) end
Drawing[_id] = Created[_id]
Marker.Run(Drawing[_id])
Marker.Run()
end,
function(markerData)
Drawing[_id] = nil
@@ -89,25 +88,29 @@ end
-- This will loop through all marker(points) in range and draw them.
-- @param data table{marker: number, position: vector3, rotation: vector3, size: vector3, color: vector3, alpha: number, bobUpAndDown: boolean, faceCamera: boolean, rotate: boolean, textureDict: string, textureName: string, drawOnEnts: boolean}
-- @return nil
function Marker.Run(data)
function Marker.Run()
if loopRunning then return end
loopRunning = true
CreateThread(function()
while loopRunning do
if not next(Created) then
loopRunning = false
return
end
for drawingId, drawingData in pairs(Drawing) do
if not Created[drawingId] then
Drawing[drawingId] = nil
goto continue
end
DrawMarker(
data.marker,
data.position.x, data.position.y, data.position.z,
drawingData.marker,
drawingData.position.x, drawingData.position.y, drawingData.position.z,
0.0, 0.0, 0.0,
data.rotation.x, data.rotation.y, data.rotation.z,
data.size.x, data.size.y, data.size.z,
data.color.x, data.color.y, data.color.z, data.alpha,
data.bobUpAndDown, data.faceCamera, false,
data.rotate, data.textureDict, data.textureName, data.drawOnEnts
drawingData.rotation.x, drawingData.rotation.y, drawingData.rotation.z,
drawingData.size.x, drawingData.size.y, drawingData.size.z,
drawingData.color.x, drawingData.color.y, drawingData.color.z, drawingData.alpha,
drawingData.bobUpAndDown, drawingData.faceCamera, false,
drawingData.rotate, drawingData.textureDict, drawingData.textureName, drawingData.drawOnEnts
)
::continue::
end
@@ -138,50 +141,6 @@ RegisterNetEvent("community_bridge:Client:MarkerRemoveBulk", function(ids)
end
end)
-- local loopRunning = false
-- function Marker.Draw()
-- if loopRunning then return end
-- loopRunning = true
-- while loopRunning do
-- Wait(0)
-- if not next(Created) then
-- Wait(1000) -- Reduce CPU usage when no markers are present
-- goto continue
-- end
-- for id, _ in pairs(Created) do
-- if Created[id] then
-- local data = Created[id]
-- if #(data.position - GetEntityCoords(PlayerPedId())) > 100.0 then
-- goto continue
-- else
-- DrawMarker(
-- data.marker,
-- data.position.x, data.position.y, data.position.z,
-- 0.0, 0.0, 0.0,
-- data.rotation.x, data.rotation.y, data.rotation.z,
-- data.size.x, data.size.y, data.size.z,
-- data.color.x, data.color.y, data.color.z, data.alpha,
-- data.bobUpAndDown, data.faceCamera, false,
-- data.rotate, data.textureDict, data.textureName, data.drawOnEnts
-- )
-- -- if data.interaction then
-- -- local playerCoords = GetEntityCoords(PlayerPedId())
-- -- local distance = #(data.position - playerCoords)
-- -- if distance < 2.0 then
-- -- if IsControlJustReleased(0, 38) then -- E key
-- -- data.interaction(data.id)
-- -- end
-- -- end
-- -- end
-- end
-- end
-- end
-- ::continue::
-- end
-- end
-- Marker.Draw() -- Start the marker drawing loop
exports("Marker", Marker)
-13
View File
@@ -8,19 +8,6 @@ function Marker.New(data)
print("Invalid marker position. Must be a vector3 with x, y, and z coordinates.")
return
end
if data.offset and (not data.offset.x or not data.offset.y or not data.offset.z) then
print("Invalid marker offset. Must be a vector3 with x, y, and z coordinates.")
return
end
if data.rotation and (not data.rotation.x or not data.rotation.y or not data.rotation.z) then
print("Invalid marker rotation. Must be a vector3 with x, y, and z coordinates.")
return
end
if not data.size or not data.size.x or not data.size.y or not data.size.z then
print("Invalid marker size. Must be a vector3 with x, y, and z dimensions.")
return
end
local _id = data.id or id.CreateUniqueId(Created)
local data = {
-6
View File
@@ -61,8 +61,6 @@ function Particle.Create(data)
assert(data.ptfx, "Invalid particle data. Must contain string ptfx.")
local _id = data.id or Ids.CreateUniqueId(Particles)
print("Creating particle", _id)
-- data for particles above
data = {
id = _id,
dict = data.dict,
@@ -110,11 +108,8 @@ end
function Particle.Remove(id)
if not id then return end
print("Removing particle1", id)
local particle = Particles[id]
print("Removing particle2", id)
if not particle then return end
print("Removing particle3", id)
Particle.Stop(particle.spawned)
Particles[id] = nil
point.Remove(id)
@@ -141,7 +136,6 @@ RegisterNetEvent("community_bridge:Client:ParticleRemove", function(id)
end)
RegisterNetEvent("community_bridge:Client:ParticleRemoveBulk", function(ids)
print("community_bridge:Client:ParticleRemoveBulk", ids)
for _, id in pairs(ids) do
Particle.Remove(id)
end