Skip to content

Commit

Permalink
fix(esx): multicharacter support
Browse files Browse the repository at this point in the history
Properly support custom multicharacter prefixes.
Disable playerConnecting event handler when using multicharacter.
  • Loading branch information
thelindat committed Jan 19, 2022
1 parent 181508c commit d42f6b9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [esx]/es_extended/server/classes/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
self.variables = {}
self.weight = weight
self.maxWeight = Config.MaxWeight
if Config.Multichar then self.license = 'license'..string.sub(identifier, 6) else self.license = 'license:'..identifier end
if Config.Multichar then self.license = 'license'.. identifier:sub(identifier:find(':'), identifier:len()) else self.license = 'license:'..identifier end

ExecuteCommand(('add_principal identifier.%s group.%s'):format(self.license, self.group))

Expand Down
28 changes: 15 additions & 13 deletions [esx]/es_extended/server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,23 @@ function createESXPlayer(identifier, playerId, data)
end
end

AddEventHandler('playerConnecting', function(name, setCallback, deferrals)
deferrals.defer()
local playerId = source
local identifier = ESX.GetIdentifier(playerId)

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 account.\n\nYour identifier: %s'):format(identifier))
if not Config.Multichar then
AddEventHandler('playerConnecting', function(name, setCallback, deferrals)
deferrals.defer()
local playerId = source
local identifier = ESX.GetIdentifier(playerId)

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 account.\n\nYour identifier: %s'):format(identifier))
else
deferrals.done()
end
else
deferrals.done()
deferrals.done('There was an error loading your character!\nError code: identifier-missing\n\nThe cause of this error is not known, your identifier could not be found. Please come back later or report this problem to the server administration team.')
end
else
deferrals.done('There was an error loading your character!\nError code: identifier-missing\n\nThe cause of this error is not known, your identifier could not be found. Please come back later or report this problem to the server administration team.')
end
end)
end)
end

function loadESXPlayer(identifier, playerId, isNew)
local userData = {
Expand Down

0 comments on commit d42f6b9

Please sign in to comment.