diff --git a/imports.lua b/imports.lua index 884eb4b5..9c5421ea 100644 --- a/imports.lua +++ b/imports.lua @@ -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) \ No newline at end of file +end) diff --git a/server/functions.lua b/server/functions.lua index b3fe38a9..a87a5a70 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -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 diff --git a/server/main.lua b/server/main.lua index 12e74141..e3911cde 100644 --- a/server/main.lua +++ b/server/main.lua @@ -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 diff --git a/version.json b/version.json index 3ff5d1a3..507a7710 100644 --- a/version.json +++ b/version.json @@ -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" }