improvement(server/main): Allow setting identity without using multicharacter

This commit is contained in:
Linden
2021-05-22 18:04:01 +10:00
committed by GitHub
parent aecc6e552c
commit e4954e6693
+9 -17
View File
@@ -120,13 +120,7 @@ function loadESXPlayer(identifier, playerId, isNew)
}
table.insert(tasks, function(cb)
local query
if Config.Multichar then
query = 'SELECT `accounts`, `job`, `job_grade`, `group`, `loadout`, `position`, `inventory`, `skin`, `firstname`, `lastname`, `dateofbirth`, `sex`, `height` FROM `users` WHERE identifier = @identifier'
else
query = 'SELECT `accounts`, `job`, `job_grade`, `group`, `loadout`, `position`, `inventory`, `skin` FROM `users` WHERE identifier = @identifier'
end
MySQL.Async.fetchAll(query, {
MySQL.Async.fetchAll('SELECT `accounts`, `job`, `job_grade`, `group`, `loadout`, `position`, `inventory`, `skin`, `firstname`, `lastname`, `dateofbirth`, `sex`, `height` FROM `users` WHERE identifier = @identifier', {
['@identifier'] = identifier
}, function(result)
local job, grade, jobObject, gradeObject = result[1].job, tostring(result[1].job_grade)
@@ -256,15 +250,13 @@ function loadESXPlayer(identifier, playerId, isNew)
end
-- Identity
if Config.Multichar then
if result[1].firstname and result[1].firstname ~= '' then
userData.firstname = result[1].firstname
userData.lastname = result[1].lastname
userData.playerName = userData.firstname..' '..userData.lastname
if result[1].dateofbirth then userData.dateofbirth = result[1].dateofbirth end
if result[1].sex then userData.sex = result[1].sex end
if result[1].height then userData.height = result[1].height end
end
if result[1].firstname and result[1].firstname ~= '' then
userData.firstname = result[1].firstname
userData.lastname = result[1].lastname
userData.playerName = userData.firstname..' '..userData.lastname
if result[1].dateofbirth then userData.dateofbirth = result[1].dateofbirth end
if result[1].sex then userData.sex = result[1].sex end
if result[1].height then userData.height = result[1].height end
end
cb()
@@ -275,7 +267,7 @@ function loadESXPlayer(identifier, playerId, isNew)
local xPlayer = CreateExtendedPlayer(playerId, identifier, userData.group, userData.accounts, userData.inventory, userData.weight, userData.job, userData.loadout, userData.playerName, userData.coords)
ESX.Players[playerId] = xPlayer
if Config.Multichar and userData.firstname then
if userData.firstname then
xPlayer.set('firstName', userData.firstname)
xPlayer.set('lastName', userData.lastname)
if userData.dateofbirth then xPlayer.set('dateofbirth', userData.dateofbirth) end