Skip to content

Commit

Permalink
refactor/fix: cleanup, remove useless code, formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpredator committed Nov 24, 2023
1 parent 234d191 commit 74354bc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 24 deletions.
3 changes: 2 additions & 1 deletion .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
37. [jsfour-idcard]: fix: value assigned to variable ESX is overwritten @bitpredator
38. [es_extended]: refactor/fix: cleanup, remove useless code, formatting @bitpredator
1 change: 0 additions & 1 deletion server-data/resources/[esx]/es_extended/client/common.lua
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
31 changes: 9 additions & 22 deletions server-data/resources/[esx]/es_extended/imports.lua
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 74354bc

Please sign in to comment.