diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 0f1ea06b7..d4fd93bd0 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -59,4 +59,5 @@ 34. [oxmysql]: chore: update to version 2.7.6 @bitpredator 35. [esx-radio] fix: fixed No such export addChannelCheck in resource pma-voice @bitpredator 36. [bpt_vehicletax]: chore: clean up the code @bitpredator -37. [jsfour-idcard]: fix: value assigned to variable ESX is overwritten @bitpredator \ No newline at end of file +37. [jsfour-idcard]: fix: value assigned to variable ESX is overwritten @bitpredator +38. [es_extended]: refactor/fix: cleanup, remove useless code, formatting @bitpredator diff --git a/server-data/resources/[esx]/es_extended/client/common.lua b/server-data/resources/[esx]/es_extended/client/common.lua index 0af9ba559..c19574a5f 100644 --- a/server-data/resources/[esx]/es_extended/client/common.lua +++ b/server-data/resources/[esx]/es_extended/client/common.lua @@ -1,5 +1,4 @@ AddEventHandler('esx:getSharedObject', function(cb) - local Invoke = GetInvokingResource() print(('[^3WARNING^7] ^5%s^7 used ^5esx:getSharedObject^7, this method is deprecated and should not be used! Refer to ^5https://bitpredator.github.io/bptdevelopment/docs/esx-tutorial/sharedevent^7 for more info!'):format(Invoke)) cb(ESX) end) diff --git a/server-data/resources/[esx]/es_extended/imports.lua b/server-data/resources/[esx]/es_extended/imports.lua index 545f1d3ce..af5d3edbc 100644 --- a/server-data/resources/[esx]/es_extended/imports.lua +++ b/server-data/resources/[esx]/es_extended/imports.lua @@ -1,36 +1,23 @@ -ESX = exports["es_extended"]:getSharedObject() +---@diagnostic disable: missing-fields +ESX = exports['es_extended']:getSharedObject() if not IsDuplicityVersion() then -- Only register this event for the client - AddEventHandler("esx:setPlayerData", function(key, val, last) - if GetInvokingResource() == "es_extended" then + AddEventHandler('esx:setPlayerData', function(key, val, last) + if GetInvokingResource() == 'es_extended' then ESX.PlayerData[key] = val - if _G.OnPlayerData then - _G.OnPlayerData(key, val, last) - end + -- if OnPlayerData then not used? + -- OnPlayerData(key, val, last) + -- end end end) - AddEventHandler("esx:playerLoaded", function(xPlayer) + RegisterNetEvent('esx:playerLoaded', function(xPlayer) ESX.PlayerData = xPlayer ESX.PlayerLoaded = true end) - AddEventHandler("esx:onPlayerLogout", function() + RegisterNetEvent('esx:onPlayerLogout', function() ESX.PlayerLoaded = false ESX.PlayerData = {} end) -else -- Only register this event for the server - local _GetPlayerFromId = ESX.GetPlayerFromId - ---@diagnostic disable-next-line: duplicate-set-field - function ESX.GetPlayerFromId(playerId) - local xPlayer = _GetPlayerFromId(playerId) - - return xPlayer and setmetatable(xPlayer, { - __index = function(self, index) - if index == "coords" then return self.getCoords() end - - return rawget(self, index) - end - }) - end end \ No newline at end of file