Replaced coords sync interval with sync every second

Because xPlayer.getCoords() has uses it cant be out of sync code
This commit is contained in:
ElPumpo
2020-04-06 12:09:06 +02:00
parent f70e1ad3ed
commit 2c2978feaa
2 changed files with 15 additions and 13 deletions
+15 -12
View File
@@ -522,24 +522,27 @@ end)
-- Update current player coords
Citizen.CreateThread(function()
local previousCoords = vector3(0, 0, 0)
-- wait for player to restore coords
while not isLoadoutLoaded do
Citizen.Wait(1000)
end
while true do
Citizen.Wait(Config.CoordsSyncInterval)
local playerPed = PlayerPedId()
local playerCoords = GetEntityCoords(playerPed)
local distance = #(playerCoords - previousCoords)
local previousCoords = vector3(ESX.PlayerData.coords.x, ESX.PlayerData.coords.y, ESX.PlayerData.coords.z)
if distance > 10 then
previousCoords = playerCoords
local playerHeading = ESX.Math.Round(GetEntityHeading(playerPed), 1)
local formattedCoords = {x = ESX.Math.Round(playerCoords.x, 1), y = ESX.Math.Round(playerCoords.y, 1), z = ESX.Math.Round(playerCoords.z, 1), heading = playerHeading}
TriggerServerEvent('esx:updateCoords', formattedCoords)
while true do
Citizen.Wait(1000)
local playerPed = PlayerPedId()
if DoesEntityExist(playerPed) then
local playerCoords = GetEntityCoords(playerPed)
local distance = #(playerCoords - previousCoords)
if distance > 1 then
previousCoords = playerCoords
local playerHeading = ESX.Math.Round(GetEntityHeading(playerPed), 1)
local formattedCoords = {x = ESX.Math.Round(playerCoords.x, 1), y = ESX.Math.Round(playerCoords.y, 1), z = ESX.Math.Round(playerCoords.z, 1), heading = playerHeading}
TriggerServerEvent('esx:updateCoords', formattedCoords)
end
end
end
end)
-1
View File
@@ -16,6 +16,5 @@ Config.EnablePvP = true -- enable pvp?
Config.MaxWeight = 24 -- the max inventory weight without backpack
Config.PaycheckInterval = 7 * 60000 -- how often to recieve pay checks in milliseconds
Config.CoordsSyncInterval = 2 * 60000 -- how often to sync coords with server in milliseconds
Config.EnableDebug = false