mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-30 01:38:52 +00:00
refactor: make Config.Multichar an automatic value
Credit to Fantik for the idea
This commit is contained in:
@@ -29,7 +29,7 @@ Config.EnableDefaultInventory = true -- Display the default Inventory ( F2 )
|
||||
Config.EnableWantedLevel = false -- Use Normal GTA wanted Level?
|
||||
Config.EnablePVP = true -- Allow Player to player combat
|
||||
|
||||
Config.Multichar = true -- Enable support for esx_multicharacter
|
||||
Config.Multichar = GetResourceState("esx_multicharacter") ~= "missing"
|
||||
Config.Identity = true -- Select a characters identity data before they have loaded in (this happens by default with multichar)
|
||||
Config.DistanceGive = 4.0 -- Max distance when giving items, weapons etc.
|
||||
|
||||
|
||||
@@ -1,29 +1,26 @@
|
||||
if not ESX then
|
||||
error('\n^1Unable to start Multicharacter - you must be using ESX Legacy^0')
|
||||
elseif ESX.GetConfig().Multichar then
|
||||
local databaseConnected = false
|
||||
local databaseFound = false
|
||||
local oneSyncState = GetConvar('onesync', 'off')
|
||||
local databaseConnected = false
|
||||
local databaseFound = false
|
||||
local oneSyncState = GetConvar('onesync', 'off')
|
||||
|
||||
local DATABASE do
|
||||
local connectionString = GetConvar('mysql_connection_string', '');
|
||||
if connectionString == '' then
|
||||
error(connectionString..'\n^1Unable to start Multicharacter - unable to determine database from mysql_connection_string^0', 0)
|
||||
elseif connectionString:find('mysql://') then
|
||||
connectionString = connectionString:sub(9, -1)
|
||||
DATABASE = connectionString:sub(connectionString:find('/')+1, -1):gsub('[%?]+[%w%p]*$', '')
|
||||
databaseFound = true
|
||||
else
|
||||
connectionString = {string.strsplit(';', connectionString)}
|
||||
for i = 1, #connectionString do
|
||||
local v = connectionString[i]
|
||||
if v:match('database') then
|
||||
DATABASE = v:sub(10, #v)
|
||||
end
|
||||
local DATABASE do
|
||||
local connectionString = GetConvar('mysql_connection_string', '');
|
||||
if connectionString == '' then
|
||||
error(connectionString..'\n^1Unable to start Multicharacter - unable to determine database from mysql_connection_string^0', 0)
|
||||
elseif connectionString:find('mysql://') then
|
||||
connectionString = connectionString:sub(9, -1)
|
||||
DATABASE = connectionString:sub(connectionString:find('/')+1, -1):gsub('[%?]+[%w%p]*$', '')
|
||||
databaseFound = true
|
||||
else
|
||||
connectionString = {string.strsplit(';', connectionString)}
|
||||
for i = 1, #connectionString do
|
||||
local v = connectionString[i]
|
||||
if v:match('database') then
|
||||
DATABASE = v:sub(10, #v)
|
||||
end
|
||||
databaseFound = true
|
||||
end
|
||||
databaseFound = true
|
||||
end
|
||||
end
|
||||
|
||||
local DB_TABLES = {users = 'identifier'}
|
||||
local FETCH = nil
|
||||
@@ -239,8 +236,4 @@ elseif ESX.GetConfig().Multichar then
|
||||
RegisterNetEvent('esx_multicharacter:relog', function()
|
||||
local source = source
|
||||
TriggerEvent('esx:playerLogout', source)
|
||||
end)
|
||||
|
||||
else
|
||||
assert(nil, '^3WARNING: Multicharacter is disabled - please check your ESX configuration^0')
|
||||
end
|
||||
end)
|
||||
Reference in New Issue
Block a user