Merge remote-tracking branch 'upstream/main' into main

This commit is contained in:
Linden
2021-07-05 22:56:47 +10:00
5 changed files with 46 additions and 15 deletions
+41 -12
View File
@@ -196,21 +196,50 @@ ESX.SavePlayer = function(xPlayer, cb)
end
ESX.SavePlayers = function(cb)
local xPlayers, asyncTasks = ESX.GetPlayers(), {}
local xPlayers = ESX.GetExtendedPlayers()
print("ESX.GetPlayers executed in es_extended saveplayers")
local selectListWithNames = "SELECT '%s' AS identifier, '%s' AS new_accounts, '%s' AS new_job, %s AS new_job_grade, '%s' AS new_group, '%s' AS new_loadout, '%s' AS new_position, '%s' AS new_inventory "
local selectListNoNames = "SELECT '%s', '%s', '%s' , %s, '%s', '%s', '%s', '%s' "
if #xPlayers > 0 then
local updateCommand = 'UPDATE users u JOIN ('
local selectList = selectListNoNames
local first = true
for k, xPlayer in pairs(xPlayers) do
if first == false then
updateCommand = updateCommand .. ' UNION '
else
selectList = selectListWithNames
end
updateCommand = updateCommand .. string.format(selectList,
xPlayer.identifier,
json.encode(xPlayer.getAccounts(true)),
xPlayer.job.name,
xPlayer.job.grade,
xPlayer.getGroup(),
json.encode(xPlayer.getLoadout(true)),
json.encode(xPlayer.getCoords()),
json.encode(xPlayer.getInventory(true))
)
first = false
end
updateCommand = updateCommand .. ' ) vals ON u.identifier = vals.identifier SET accounts = new_accounts, job = new_job, job_grade = new_job_grade, `group` = new_group, loadout = new_loadout, `position` = new_position, inventory = new_inventory'
MySQL.Async.execute(updateCommand)
print(('[es_extended] [^2INFO^7] Saved %s player(s)'):format(#xPlayers))
for i=1, #xPlayers, 1 do
table.insert(asyncTasks, function(cb2)
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
ESX.SavePlayer(xPlayer, cb2)
end)
end
Async.parallelLimit(asyncTasks, 8, function(results)
print(('[^2INFO^7] Saved ^5%s^0 player(s)'):format(#xPlayers))
if cb then
cb()
end
end)
if cb then
cb()
end
end
ESX.StartDBSync = function()
+2 -1
View File
@@ -123,6 +123,7 @@ AddEventHandler('esx_jobs:action', function(job, zone, zoneKey)
local plate = GetVehicleNumberPlateText(vehicle)
plate = string.gsub(plate, " ", "")
local driverPed = GetPedInVehicleSeat(vehicle, -1)
local vehicleMaxHealth = GetVehicleEngineHealth(vehicle)
if playerPed == driverPed then
@@ -524,4 +525,4 @@ Citizen.CreateThread(function()
RequestIpl("id2_14_during1")
end)
if ESX.PlayerLoaded then refreshBlips() end
if ESX.PlayerLoaded then refreshBlips() end
+1 -1
View File
@@ -108,7 +108,7 @@ AddEventHandler('esx_jobs:caution', function(cautionType, cautionAmount, spawnPo
local xPlayer = ESX.GetPlayerFromId(source)
if cautionType == 'take' then
if cautionAmount <= Config.MaxCaution and cautionAmount > 0 then
if cautionAmount <= Config.MaxCaution and cautionAmount >= 0 then
TriggerEvent('esx_addonaccount:getAccount', 'caution', xPlayer.identifier, function(account)
if xPlayer.getAccount('bank').money >= cautionAmount then
xPlayer.removeAccountMoney('bank', cautionAmount)
+1 -1
View File
@@ -416,7 +416,7 @@ function OpenIdentityCardMenu(player)
table.insert(elements, {label = _U('height', data.height)})
end
if data.drunk then
if Config.EnableESXOptionalneeds and data.drunk then
table.insert(elements, {label = _U('bac', data.drunk)})
end
+1
View File
@@ -8,6 +8,7 @@ Config.MarkerColor = {r = 50, g = 50, b = 204}
Config.EnablePlayerManagement = true -- Enable if you want society managing.
Config.EnableArmoryManagement = false
Config.EnableESXIdentity = true -- Enable if you're using esx_identity.
Config.EnableESXOptionalneeds = false -- Enable if you're using esx_optionalneeds
Config.EnableLicenses = false -- Enable if you're using esx_license.
Config.EnableHandcuffTimer = true -- Enable handcuff timer? will unrestrain player after the time ends.