fix(es_extended/imports.lua): Update Metatable On Imports

This commit is contained in:
Meyndflay
2025-06-12 07:23:44 +08:00
parent c10097df4f
commit fe456264a5
2 changed files with 24 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
.DS_Store
+23
View File
@@ -3,7 +3,28 @@ ESX.currentResourceName = GetCurrentResourceName()
OnPlayerData = function (key, val, last) end OnPlayerData = function (key, val, last) end
local function TrackPedCoordsOnce()
ESX.PlayerData.coords = nil
setmetatable(ESX.PlayerData, {
__index = function(self, key)
if key ~= "coords" then
return
end
local coords = GetEntityCoords(ESX.PlayerData.ped)
return coords
end
})
end
if not IsDuplicityVersion() then -- Only register this event for the client if not IsDuplicityVersion() then -- Only register this event for the client
-- On Resource Start
local OnStart = (function()
TrackPedCoordsOnce()
end)()
AddEventHandler("esx:setPlayerData", function(key, val, last) AddEventHandler("esx:setPlayerData", function(key, val, last)
if GetInvokingResource() == "es_extended" then if GetInvokingResource() == "es_extended" then
ESX.PlayerData[key] = val ESX.PlayerData[key] = val
@@ -17,6 +38,8 @@ if not IsDuplicityVersion() then -- Only register this event for the client
ESX.PlayerData = xPlayer ESX.PlayerData = xPlayer
while not ESX.PlayerData.ped or not DoesEntityExist(ESX.PlayerData.ped) do Wait(0) end while not ESX.PlayerData.ped or not DoesEntityExist(ESX.PlayerData.ped) do Wait(0) end
ESX.PlayerLoaded = true ESX.PlayerLoaded = true
TrackPedCoordsOnce()
end) end)
ESX.SecureNetEvent("esx:onPlayerLogout", function() ESX.SecureNetEvent("esx:onPlayerLogout", function()