For those using ESX it needs to use it with some operations
save sql data to database
enter file es_extended>server>main.lua
delete these codes
First, enter the config.lua file and set Config.Multichar false.
For those using ESX it needs to use it with some operations
save sql data to database
enter file es_extended>server>main.lua
delete these codes
local StringCharset = {}
local NumberCharset = {}
for i = 48, 57 do table.insert(NumberCharset, string.char(i)) end
for i = 65, 90 do table.insert(StringCharset, string.char(i)) end
for i = 97, 122 do table.insert(StringCharset, string.char(i)) end
function RandomStr(length)
if length > 0 then
return RandomStr(length-1) .. StringCharset[math.random(1, #StringCharset)]
else
return ''
end
end
function RandomInt(length)
if length > 0 then
return RandomInt(length-1) .. NumberCharset[math.random(1, #NumberCharset)]
else
return ''
end
end
function SplitStr(str, delimiter)
local result = { }
local from = 1
local delim_from, delim_to = string.find( str, delimiter, from )
while delim_from do
table.insert( result, string.sub( str, from , delim_from-1 ) )
from = delim_to + 1
delim_from, delim_to = string.find( str, delimiter, from )
end
table.insert( result, string.sub( str, from ) )
return result
end
ESX.Login = function(source, citizenid, newData)
if source ~= nil then
if citizenid ~= false then
loadESXPlayer(citizenid,source)
else
local accounts = {}
for account,money in pairs(Config.StartingAccountMoney) do
accounts[account] = money
end
local playerData = {}
local identifier
local charinfo = {}
firstname = newData.charinfo.firstname
lastname = newData.charinfo.lastname
sex = newData.charinfo.sex
birthdate = newData.charinfo.date
cid = newData.cid
-- local citizenId = GetPlayerIdentifiers(source)[1]
local citizenId = CreateCharId(source)
MySQL.Async.execute('INSERT INTO users (accounts, identifier, lastname, firstname, sex, dateofbirth) VALUES (@accounts, @identifier, @lastname, @firstname, @sex, @dateofbirth)', {
['@accounts'] = json.encode(accounts),
['@identifier'] = citizenId,
['@firstname'] = firstname,
['@lastname'] = lastname,
['@sex'] = sex,
['@dateofbirth'] = birthdate
}, function(rowsChanged)
loadESXPlayer(citizenId,source)
end)
end
return true
else
return false
end
end
function CreateCharId(source)
local UniqueFound = false
local CitizenId = nil
local ilkdeneme = false
local rakam = 0
while not UniqueFound do
if not ilkdeneme then
CitizenId = GetPlayerIdentifiers(source)[1]
local result = MySQL.Sync.fetchAll("SELECT * FROM users WHERE identifier LIKE '%"..CitizenId.."%'", {})
if #result == 0 then
UniqueFound = true
else
ilkdeneme = true
end
else
rakam = rakam + 1
CitizenId = "Char:".. rakam .. string.sub(GetPlayerIdentifiers(source)[1], 6)
local result = MySQL.Sync.fetchAll("SELECT * FROM users WHERE identifier LIKE '%"..CitizenId.."%'", {})
if #result == 0 then
UniqueFound = true
end
end
end
local CitizenId = CitizenId
return CitizenId
end
local StringCharset = {}
local NumberCharset = {}
for i = 48, 57 do table.insert(NumberCharset, string.char(i)) end
for i = 65, 90 do table.insert(StringCharset, string.char(i)) end
for i = 97, 122 do table.insert(StringCharset, string.char(i)) end
function RandomStr(length)
if length > 0 then
return RandomStr(length-1) .. StringCharset[math.random(1, #StringCharset)]
else
return ''
end
end
function RandomInt(length)
if length > 0 then
return RandomInt(length-1) .. NumberCharset[math.random(1, #NumberCharset)]
else
return ''
end
end
function SplitStr(str, delimiter)
local result = { }
local from = 1
local delim_from, delim_to = string.find( str, delimiter, from )
while delim_from do
table.insert( result, string.sub( str, from , delim_from-1 ) )
from = delim_to + 1
delim_from, delim_to = string.find( str, delimiter, from )
end
table.insert( result, string.sub( str, from ) )
return result
end
ESX.Login = function(source, citizenid, newData)
if source ~= nil then
if citizenid ~= false then
loadESXPlayer(citizenid,source)
else
local accounts = {}
for account,money in pairs(Config.StartingAccountMoney) do
accounts[account] = money
end
local playerData = {}
local identifier
local charinfo = {}
firstname = newData.charinfo.firstname
lastname = newData.charinfo.lastname
sex = newData.charinfo.sex
birthdate = newData.charinfo.date
cid = newData.cid
-- local citizenId = GetPlayerIdentifiers(source)[1]
local citizenId = CreateCharId(source)
exports.ghmattimysql:execute('INSERT INTO users (accounts, identifier, lastname, firstname, sex, dateofbirth) VALUES (@accounts, @identifier, @lastname, @firstname, @sex, @dateofbirth)', {
['@accounts'] = json.encode(accounts),
['@identifier'] = citizenId,
['@firstname'] = firstname,
['@lastname'] = lastname,
['@sex'] = sex,
['@dateofbirth'] = birthdate
}, function(rowsChanged)
loadESXPlayer(citizenId,source)
end)
end
return true
else
return false
end
end
function CreateCharId(source)
local UniqueFound = false
local CitizenId = nil
local ilkdeneme = false
local rakam = 0
while not UniqueFound do
if not ilkdeneme then
CitizenId = GetPlayerIdentifiers(source)[1]
local result = exports.ghmattimysql:executeSync("SELECT * FROM users WHERE identifier LIKE '%"..CitizenId.."%'", {})
if #result == 0 then
UniqueFound = true
else
ilkdeneme = true
end
else
rakam = rakam + 1
CitizenId = "Char:".. rakam .. string.sub(GetPlayerIdentifiers(source)[1], 6)
local result = exports.ghmattimysql:executeSync("SELECT * FROM users WHERE identifier LIKE '%"..CitizenId.."%'", {})
if #result == 0 then
UniqueFound = true
end
end
end
local CitizenId = CitizenId
return CitizenId
end
local StringCharset = {}
local NumberCharset = {}
for i = 48, 57 do table.insert(NumberCharset, string.char(i)) end
for i = 65, 90 do table.insert(StringCharset, string.char(i)) end
for i = 97, 122 do table.insert(StringCharset, string.char(i)) end
function RandomStr(length)
if length > 0 then
return RandomStr(length-1) .. StringCharset[math.random(1, #StringCharset)]
else
return ''
end
end
function RandomInt(length)
if length > 0 then
return RandomInt(length-1) .. NumberCharset[math.random(1, #NumberCharset)]
else
return ''
end
end
function SplitStr(str, delimiter)
local result = { }
local from = 1
local delim_from, delim_to = string.find( str, delimiter, from )
while delim_from do
table.insert( result, string.sub( str, from , delim_from-1 ) )
from = delim_to + 1
delim_from, delim_to = string.find( str, delimiter, from )
end
table.insert( result, string.sub( str, from ) )
return result
end
ESX.Login = function(source, citizenid, newData)
if source ~= nil then
if citizenid ~= false then
loadESXPlayer(citizenid,source)
else
local accounts = {}
for account,money in pairs(Config.StartingAccountMoney) do
accounts[account] = money
end
local playerData = {}
local identifier
local charinfo = {}
firstname = newData.charinfo.firstname
lastname = newData.charinfo.lastname
sex = newData.charinfo.sex
birthdate = newData.charinfo.date
cid = newData.cid
-- local citizenId = GetPlayerIdentifiers(source)[1]
local citizenId = CreateCharId(source)
exports.oxmysql:execute('INSERT INTO users (accounts, identifier, lastname, firstname, sex, dateofbirth) VALUES (@accounts, @identifier, @lastname, @firstname, @sex, @dateofbirth)', {
['@accounts'] = json.encode(accounts),
['@identifier'] = citizenId,
['@firstname'] = firstname,
['@lastname'] = lastname,
['@sex'] = sex,
['@dateofbirth'] = birthdate
}, function(rowsChanged)
loadESXPlayer(citizenId,source)
end)
end
return true
else
return false
end
end
function CreateCharId(source)
local UniqueFound = false
local CitizenId = nil
local ilkdeneme = false
local rakam = 0
while not UniqueFound do
if not ilkdeneme then
CitizenId = GetPlayerIdentifiers(source)[1]
local result = exports.oxmysql:executeSync("SELECT * FROM users WHERE identifier LIKE '%"..CitizenId.."%'", {})
if #result == 0 then
UniqueFound = true
else
ilkdeneme = true
end
else
rakam = rakam + 1
CitizenId = "Char:".. rakam .. string.sub(GetPlayerIdentifiers(source)[1], 6)
local result = exports.oxmysql:executeSync("SELECT * FROM users WHERE identifier LIKE '%"..CitizenId.."%'", {})
if #result == 0 then
UniqueFound = true
end
end
end
local CitizenId = CitizenId
return CitizenId
end