Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create markers.lua #1316

Closed
wants to merge 5 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions [core]/es_extended/client/modules/points.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
local Markers = {}

---@func fun(coords: vector3, radius: number, data?: any)
function ESX.CreateMarker(data)
local Index = #Points+1
Markers[Index] = data
return Markers[Index]
end

CreateThread(function()
while true do
Wait(0)
local InPoint = false
fusion-develops marked this conversation as resolved.
Show resolved Hide resolved
local Coords = GetEntityCoords(ESX.PlayerData.Ped)
for i = 1, #Markers do
local Marker = Markers[i]
Marker.distance = #(Coords - Marker.Coords)
fusion-develops marked this conversation as resolved.
Show resolved Hide resolved
if Marker.distance < Marker.radius then
if Marker.status and Marker.Inside then
fusion-develops marked this conversation as resolved.
Show resolved Hide resolved
Marker:Inside()
InPoint = true
elseif Marker.Inside and not Marker.status then
Marker.status = true
InPoint = true
if Marker.Entered then
Marker:Entered()
end
end
elseif Marker.inside then
Marker.status = false
if Marker.Exited then
Marker:Exited()
end
InPoint = false
end
end
if not InPoint then
Wait(1500)
end
end
end)


local Marker = ESX.CreateMarker({coords = vec(1,1,1), radius = 5})

function Marker:Inside()
-- Loops
print(json.encode(self)) -- coords, radius, inside, distance

end

function Marker:Exited()
-- Tick
print(json.encode(self)) -- coords, radius, inside, distance
end

function Marker:Entered()
-- Tick
print(json.encode(self)) -- coords, radius, inside, distance
end