mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-30 01:38:52 +00:00
feat(es_extended/imports): add support for resolving player identifier
This commit is contained in:
@@ -45,7 +45,13 @@ if not IsDuplicityVersion() then -- Only register this event for the client
|
||||
else
|
||||
ESX.Player = setmetatable({}, {
|
||||
__call = function(_, src)
|
||||
if not ESX.IsPlayerLoaded(src) then return end
|
||||
if type(src) ~= "number" then
|
||||
src = ESX.GetPlayerIdFromIdentifier(src)
|
||||
if not src then return end
|
||||
elseif not ESX.IsPlayerLoaded(src) then
|
||||
return
|
||||
end
|
||||
|
||||
return setmetatable({src = src}, {
|
||||
__index = function(self, method)
|
||||
return function(...)
|
||||
|
||||
@@ -358,6 +358,12 @@ function ESX.GetPlayerFromIdentifier(identifier)
|
||||
return Core.playersByIdentifier[identifier]
|
||||
end
|
||||
|
||||
---@param identifier string
|
||||
---@return number playerId
|
||||
function ESX.GetPlayerIdFromIdentifier(identifier)
|
||||
return Core.playersByIdentifier[identifier]?.source
|
||||
end
|
||||
|
||||
---@param source number
|
||||
---@return boolean
|
||||
function ESX.IsPlayerLoaded(source)
|
||||
|
||||
Reference in New Issue
Block a user