Merge pull request #1128 from thelindat/legacy

fix+feat(legacy) Server event 'esx:playerLoaded' | Call function in import | Added function to get identifier
This commit is contained in:
FuraXx
2021-05-09 21:53:37 +02:00
committed by GitHub
4 changed files with 19 additions and 23 deletions
+2 -1
View File
@@ -3,5 +3,6 @@ ESX = exports['es_extended']:getSharedObject()
AddEventHandler('esx:setPlayerData', function(key, val)
if GetInvokingResource() == 'es_extended' then
ESX.PlayerData[key] = val
if OnPlayerData ~= nil then OnPlayerData(key, val) end
end
end)
end)
+9
View File
@@ -239,6 +239,15 @@ ESX.GetPlayerFromIdentifier = function(identifier)
end
end
ESX.GetIdentifier = function(playerId)
for k,v in ipairs(GetPlayerIdentifiers(playerId)) do
if string.match(v, 'license') then
local identifier = string.gsub(v, 'license:', '')
return identifier
end
end
end
ESX.RegisterUsableItem = function(item, cb)
ESX.UsableItemsCallbacks[item] = cb
end
+6 -20
View File
@@ -11,15 +11,7 @@ AddEventHandler('esx:onPlayerJoined', function()
end)
function onPlayerJoined(playerId)
local identifier
for k,v in ipairs(GetPlayerIdentifiers(playerId)) do
if string.match(v, 'license:') then
identifier = string.sub(v, 9)
break
end
end
local identifier = ESX.GetIdentifier(playerId)
if identifier then
if ESX.GetPlayerFromIdentifier(identifier) then
@@ -61,20 +53,13 @@ end
AddEventHandler('playerConnecting', function(name, setCallback, deferrals)
deferrals.defer()
local playerId, identifier = source
local playerId = source
local identifier = ESX.GetIdentifier(playerId)
Citizen.Wait(100)
for k,v in ipairs(GetPlayerIdentifiers(playerId)) do
if string.match(v, 'license:') then
identifier = string.sub(v, 9)
break
end
end
if identifier then
if ESX.GetPlayerFromIdentifier(identifier) then
deferrals.done(('There was an error loading your character!\nError code: identifier-active\n\nThis error is caused by a player on this server who has the same identifier as you have. Make sure you are not playing on the same Rockstar account.\n\nYour Rockstar identifier: %s'):format(identifier))
deferrals.done(('There was an error loading your character!\nError code: identifier-active\n\nThis error is caused by a player on this server who has the same identifier as you have. Make sure you are not playing on the same account.\n\nYour identifier: %s'):format(identifier))
else
deferrals.done()
end
@@ -225,6 +210,7 @@ function loadESXPlayer(identifier, playerId, isNew)
Async.parallel(tasks, function(results)
local xPlayer = CreateExtendedPlayer(playerId, identifier, userData.group, userData.accounts, userData.inventory, userData.weight, userData.job, userData.loadout, userData.playerName, userData.coords)
ESX.Players[playerId] = xPlayer
TriggerEvent('esx:playerLoaded', playerId, xPlayer, isNew)
xPlayer.triggerEvent('esx:playerLoaded', {
accounts = xPlayer.getAccounts(),
@@ -539,7 +525,7 @@ Citizen.CreateThread(
([[
^1----------------------------------------------------------------------
^1URGENT: YOUR ES-EXTENDED IS OUTDATATED!!!
^1URGENT: YOUR ES-EXTENDED IS OUTDATED!
^1COMMIT UPDATE: ^5%s AVAILABLE
^1DOWNLOAD:^5 https://github.com/esx-framework/es_extended/tree/legacy
^1CHANGELOG:^5 %s
+2 -2
View File
@@ -1,5 +1,5 @@
{
"version": "legacy",
"commit" : "1.1.9",
"changelog": "Fix esx_identity"
"commit" : "1.1.10",
"changelog": "function improvements; new import file and functions"
}