Skip to content
This repository has been archived by the owner on Mar 21, 2022. It is now read-only.

Commit

Permalink
fix(server): connection string parser
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed Dec 1, 2021
1 parent 150ec16 commit 874eeef
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
36 changes: 16 additions & 20 deletions server/main.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 874eeef

Please sign in to comment.