-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor/fix: cleanup, remove useless code, formatting
- Loading branch information
1 parent
234d191
commit 74354bc
Showing
3 changed files
with
11 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |