Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor/fix: cleanup, remove useless code, formatting #566

Merged
merged 4 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@
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 +
fix lint error: unused argument last; accessing undefined variable Invoke; unused variable targetCoords @bitpredator
12 changes: 5 additions & 7 deletions server-data/resources/[esx]/es_extended/client/common.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
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)

exports('getSharedObject', function()
return ESX
end)

if GetResourceState('ox_inventory') ~= 'missing' then
Config.OxInventory = true
end
end

RegisterNetEvent('esx:getSharedObject', function()
print(('[^1ERROR^7] Resource ^5%s^7 Used the ^5getSharedObject^7 Event, this event ^1no longer exists!^7 Visit https://bitpredator.github.io/bptdevelopment/docs/esx-tutorial/sharedevent for how to fix!'):format(GetInvokingResource))
end)
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)
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
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ end, true, {
})

ESX.RegisterCommand('bring', "admin", function(xPlayer, args)
local targetCoords = args.playerId.getCoords()
local playerCoords = xPlayer.getCoords()
args.playerId.setCoords(playerCoords)
end, true, {
Expand Down
Loading