refactor: move server settings to config

Added support for sv_lan to allow use with FxDK.
Added support for ESX forks with Config.Identifier
This commit is contained in:
Linden
2021-10-29 11:09:30 +11:00
parent 3fe1f438df
commit a9960ef3f5
2 changed files with 16 additions and 7 deletions
+11
View File
@@ -6,6 +6,17 @@ if IsDuplicityVersion() then
-- If you want to manage extra slots for specific players you can do it by using '/setslots' and '/remslots' commands
Config.Slots = 4
--------------------
-- Text to prepend to each character (char#:identifier) - keep it short
-- if you modify this, you will need to modify es_extended due to an oversight!
-- https://github.com/esx-framework/esx-legacy/blob/main/%5Besx%5D/es_extended/server/classes/player.lua#L17
-- if Config.Multichar then self.license = 'license'..identifier:sub(identifier:find(':')) else self.license = 'license:'..identifier end
Config.Prefix = 'char'
--------------------
-- Default identifier to store for characters - this should always match es_extended (recommended: license)
Config.Identifier = 'license'
else
-- Sets the location for the character selection scene
-- To set the spawn location for new characters, modify the default value in the `users` SQL table
+5 -7
View File
@@ -25,14 +25,12 @@ elseif ESX.GetConfig().Multichar == true then
DATABASE = DATABASE()
local DB_TABLES = {}
local FETCH = nil
local PREFIX = 'char'
-- enter a prefix to prepend to all user identifiers (keep it short)
-- if you modify this, you will need to modify es_extended due to an oversight!
-- https://github.com/esx-framework/esx-legacy/blob/main/%5Besx%5D/es_extended/server/classes/player.lua#L17
-- if Config.Multichar then self.license = 'license'..identifier:sub(identifier:find(':')) else self.license = 'license:'..identifier end
local SLOTS = Config.Slots or 4
local PREFIX = Config.Prefix or 'char'
local PRIMARY_IDENTIFIER = ESX.GetConfig().Identifier or GetConvar('sv_lan', '') == 'true' and 'ip' or Config.Identifier
local function GetIdentifier(source)
local identifier = 'license:'
local identifier = PRIMARY_IDENTIFIER..':'
for _, v in pairs(GetPlayerIdentifiers(source)) do
if string.match(v, identifier) then
identifier = string.gsub(v, identifier, '')
@@ -52,7 +50,7 @@ elseif ESX.GetConfig().Multichar == true then
local identifier = GetIdentifier(source)
local slots = MySQL.Sync.fetchScalar("SELECT slots FROM multicharacter_slots WHERE identifier = ?", {
identifier
}) or Config.Slots
}) or SLOTS
identifier = PREFIX..'%:'..identifier
MySQL.Async.fetchAll(FETCH, {identifier, slots}, function(result)