Skip to content

Commit

Permalink
refactor: Convar to use FiveM identifier as main
Browse files Browse the repository at this point in the history
  • Loading branch information
Mycroft-Studios committed Dec 8, 2024
1 parent 7958934 commit eeddf8a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 2 additions & 0 deletions [core]/es_extended/server/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Core.playersByIdentifier = {}

Core.vehicleTypesByModel = {}

ESX.identifierType = GetConvar("esx:useFiveMId", "false") == "true" and "fivem" or "license"

RegisterNetEvent("esx:onPlayerSpawn", function()
ESX.Players[source].spawned = true
end)
Expand Down
4 changes: 2 additions & 2 deletions [core]/es_extended/server/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ function ESX.GetIdentifier(playerId)

playerId = tostring(playerId)

local identifier = GetPlayerIdentifierByType(playerId, "license")
return identifier and identifier:gsub("license:", "")
local identifier = GetPlayerIdentifierByType(playerId, ESX.identifierType)
return identifier and identifier:gsub(ESX.identifierType, "")
end

---@param model string|number
Expand Down
1 change: 0 additions & 1 deletion [core]/esx_multicharacter/server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Server._index = Server
Server.oneSync = GetConvar("onesync", "off")
Server.slots = Config.Slots or 4
Server.prefix = Config.Prefix or "char"
Server.identifierType = ESX.GetConfig().Identifier or GetConvar("sv_lan", "") == "true" and "ip" or "license"

AddEventHandler("playerConnecting", function(_, _, deferrals)
local source = source
Expand Down
4 changes: 2 additions & 2 deletions [core]/esx_multicharacter/server/modules/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ function Server:OnConnecting(source, deferrals)
if identifier then
if not ESX.GetConfig().EnableDebug then
if ESX.Players[identifier] then
deferrals.done(("[ESX Multicharacter] A player is already connected to the server with this identifier.\nYour identifier: %s:%s"):format(Server.identifierType, identifier))
deferrals.done(("[ESX Multicharacter] A player is already connected to the server with this identifier.\nYour identifier: %s:%s"):format(ESX.identifierType, identifier))
else
deferrals.done()
end
else
deferrals.done()
end
else
deferrals.done(("[ESX Multicharacter] Unable to retrieve player identifier.\nIdentifier type: %s"):format(Server.identifierType))
deferrals.done(("[ESX Multicharacter] Unable to retrieve player identifier.\nIdentifier type: %s"):format(ESX.identifierType))
end
end

Expand Down

0 comments on commit eeddf8a

Please sign in to comment.