mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 05:02:15 +00:00
fix(server): connection string parser
This commit is contained in:
+1
-1
@@ -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 {
|
||||
|
||||
+18
-22
@@ -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)
|
||||
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)
|
||||
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 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
|
||||
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
|
||||
|
||||
local DB_TABLES = {}
|
||||
local FETCH = nil
|
||||
local SLOTS = Config.Slots or 4
|
||||
|
||||
Reference in New Issue
Block a user