mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 16:23:21 +00:00
improvement(server/main): Create a stored query for creating new users
This commit is contained in:
+22
-14
@@ -1,6 +1,10 @@
|
|||||||
|
local NewPlayer = -1
|
||||||
Citizen.CreateThread(function()
|
Citizen.CreateThread(function()
|
||||||
SetMapName('San Andreas')
|
SetMapName('San Andreas')
|
||||||
SetGameType('ESX Roleplay')
|
SetGameType('ESX Roleplay')
|
||||||
|
MySQL.Async.store("INSERT INTO users SET ?", function(storeId)
|
||||||
|
NewPlayer = storeId
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local awaitingRegistration = {}
|
local awaitingRegistration = {}
|
||||||
@@ -24,7 +28,7 @@ end
|
|||||||
|
|
||||||
function onPlayerJoined(playerId, char, isNew)
|
function onPlayerJoined(playerId, char, isNew)
|
||||||
local identifier = ESX.GetIdentifier(playerId)
|
local identifier = ESX.GetIdentifier(playerId)
|
||||||
if char then identifier = 'char'..char..':'..identifier end
|
if char then identifier = char..':'..identifier end
|
||||||
|
|
||||||
if identifier then
|
if identifier then
|
||||||
if ESX.GetPlayerFromIdentifier(identifier) then
|
if ESX.GetPlayerFromIdentifier(identifier) then
|
||||||
@@ -60,10 +64,12 @@ function createESXPlayer(identifier, playerId)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not Config.Multichar then
|
if not Config.Multichar then
|
||||||
MySQL.Async.execute('INSERT INTO users (`accounts`, `identifier`, `group`) VALUES (@accounts, @identifier, @group)', {
|
MySQL.Async.execute(NewPlayer, {
|
||||||
['@accounts'] = json.encode(accounts),
|
{
|
||||||
['@identifier'] = identifier,
|
['accounts'] = json.encode(accounts),
|
||||||
['@group'] = defaultGroup
|
['identifier'] = identifier,
|
||||||
|
['group'] = defaultGroup,
|
||||||
|
}
|
||||||
}, function(rowsChanged)
|
}, function(rowsChanged)
|
||||||
loadESXPlayer(identifier, playerId, true)
|
loadESXPlayer(identifier, playerId, true)
|
||||||
end)
|
end)
|
||||||
@@ -75,15 +81,17 @@ function createESXPlayer(identifier, playerId)
|
|||||||
if awaitingRegistration[playerId] ~= true then data = awaitingRegistration[playerId] break end
|
if awaitingRegistration[playerId] ~= true then data = awaitingRegistration[playerId] break end
|
||||||
end
|
end
|
||||||
awaitingRegistration[playerId] = nil
|
awaitingRegistration[playerId] = nil
|
||||||
MySQL.Async.execute('INSERT INTO users (`accounts`, `identifier`, `group`, `firstname`, `lastname`, `dateofbirth`, `sex`, `height`) VALUES (@accounts, @identifier, @group, @firstname, @lastname, @dateofbirth, @sex, @height)', {
|
MySQL.Async.execute(NewPlayer, {
|
||||||
['@accounts'] = json.encode(accounts),
|
{
|
||||||
['@identifier'] = identifier,
|
['accounts'] = json.encode(accounts),
|
||||||
['@group'] = defaultGroup,
|
['identifier'] = identifier,
|
||||||
['@firstname'] = data.firstname,
|
['group'] = defaultGroup,
|
||||||
['@lastname'] = data.lastname,
|
['firstname'] = data.firstname,
|
||||||
['@dateofbirth'] = data.dateofbirth,
|
['lastname'] = data.lastname,
|
||||||
['@sex'] = data.sex,
|
['dateofbirth'] = data.dateofbirth,
|
||||||
['@height'] = data.height,
|
['sex'] = data.sex,
|
||||||
|
['height'] = data.height,
|
||||||
|
}
|
||||||
}, function(rowsChanged)
|
}, function(rowsChanged)
|
||||||
loadESXPlayer(identifier, playerId, true)
|
loadESXPlayer(identifier, playerId, true)
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user