diff --git a/fxmanifest.lua b/fxmanifest.lua index 503a7fb..f93b5e3 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -1,7 +1,7 @@ fx_version 'cerulean' game 'gta5' description 'https://github.com/thelindat/esx_multicharacter' -version '1.4.1' +version '1.4.2' lua54 'yes' dependencies { diff --git a/server/main.lua b/server/main.lua index 5becd5c..cb4ad80 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1,28 +1,24 @@ -local function DATABASE() - 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 - if connectionString:find('?*$') then - return connectionString:match('[^/][%w]*[?$]'):sub(0, -2) +if not ESX then + error('\n^1Unable to start Multicharacter - you must be using ESX Legacy^0') +elseif ESX.GetConfig().Multichar == true then + 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]*$', '') else - return connectionString:match('[^/][%w]*$') - end - else - connectionString = {string.strsplit(';', connectionString)} - for i=1, #connectionString do - local v = connectionString[i] - if v:match('database') then - return v:sub(10, #v) + connectionString = {string.strsplit(';', connectionString)} + for i=1, #connectionString do + local v = connectionString[i] + if v:match('database') then + DATABASE = v:sub(10, #v) + end end end end -end -if not ESX then - error('\n^1Unable to start Multicharacter - you must be using ESX Legacy^0') -elseif ESX.GetConfig().Multichar == true then - DATABASE = DATABASE() local DB_TABLES = {} local FETCH = nil local SLOTS = Config.Slots or 4