mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 08:13:21 +00:00
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:
+15
-12
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user