mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 16:23:21 +00:00
Merge pull request #1443 from Kenshiin13/points-module
fix(client/modules/points): Small improvements.
This commit is contained in:
@@ -6,7 +6,7 @@ function Point:constructor(properties)
|
||||
self.inside = properties.inside or function() end
|
||||
self.enter = properties.enter or function() end
|
||||
self.leave = properties.leave or function() end
|
||||
self.handle = ESX.CreatePointIntenal(properties.coords, properties.distance, properties.hidden, function()
|
||||
self.handle = ESX.CreatePointInternal(properties.coords, properties.distance, properties.hidden, function()
|
||||
self.nearby = true
|
||||
if self.enter then
|
||||
self:enter()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
local points = {}
|
||||
|
||||
function ESX.CreatePointIntenal(coords, distance, hidden, enter, leave)
|
||||
function ESX.CreatePointInternal(coords, distance, hidden, enter, leave)
|
||||
local point = {
|
||||
coords = coords,
|
||||
distance = distance,
|
||||
@@ -28,8 +28,7 @@ function StartPointsLoop()
|
||||
CreateThread(function()
|
||||
while true do
|
||||
local coords = GetEntityCoords(ESX.PlayerData.ped)
|
||||
for i=1, #points do
|
||||
local point = points[i]
|
||||
for i, point in pairs(points) do
|
||||
local distance = #(coords - point.coords)
|
||||
|
||||
if not point.hidden and distance <= point.distance then
|
||||
@@ -50,9 +49,9 @@ end
|
||||
|
||||
|
||||
AddEventHandler('onResourceStop', function(resource)
|
||||
for i=1, #points do
|
||||
if points[i].resource == resource then
|
||||
points[i] = nil
|
||||
end
|
||||
end
|
||||
for i, point in pairs(points) do
|
||||
if point.resource == resource then
|
||||
points[i] = nil
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user