From 5aedcd0c33064951ee7034346b1d993938c901fd Mon Sep 17 00:00:00 2001 From: Meyndflay Date: Mon, 9 Jun 2025 18:44:13 +0800 Subject: [PATCH] feat(es_extended): Optimize Tracking Of Ped Coords --- [core]/es_extended/client/modules/actions.lua | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/[core]/es_extended/client/modules/actions.lua b/[core]/es_extended/client/modules/actions.lua index 98b864b1..8308c017 100644 --- a/[core]/es_extended/client/modules/actions.lua +++ b/[core]/es_extended/client/modules/actions.lua @@ -40,6 +40,28 @@ function Actions:TrackPedCoords() ESX.SetPlayerData("coords", coords) end +function Actions:TrackPedCoordsOnce() + CreateThread(function() + while not ESX.IsPlayerLoaded() then + Wait(250) + end + + ESX.PlayerData.coords = nil + + setmetatable(ESX.PlayerData, { + __index = function(self, key) + if key ~= "coords" then + return + end + + local coords = GetEntityCoords(ESX.PlayerData.ped) + + return { x = coords.x, y = coords.y, z = coords.z } + end + }) + end) +end + function Actions:TrackPed() local playerPed = ESX.PlayerData.ped local newPed = PlayerPedId() @@ -193,7 +215,7 @@ end function Actions:SlowLoop() CreateThread(function() while ESX.PlayerLoaded do - self:TrackPedCoords() + -- self:TrackPedCoords() self:TrackPauseMenu() self:TrackVehicle() self:TrackWeapon() @@ -217,3 +239,4 @@ function Actions:Init() end Actions:Init() +Actions:TrackPedCoordsOnce()