diff --git a/[esx]/es_extended/server/functions.lua b/[esx]/es_extended/server/functions.lua index a1d3977c..3e61fee7 100644 --- a/[esx]/es_extended/server/functions.lua +++ b/[esx]/es_extended/server/functions.lua @@ -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() diff --git a/[esx_addons]/esx_jobs/client/main.lua b/[esx_addons]/esx_jobs/client/main.lua index 7ea82e12..6c2def93 100644 --- a/[esx_addons]/esx_jobs/client/main.lua +++ b/[esx_addons]/esx_jobs/client/main.lua @@ -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 \ No newline at end of file +if ESX.PlayerLoaded then refreshBlips() end diff --git a/[esx_addons]/esx_jobs/server/main.lua b/[esx_addons]/esx_jobs/server/main.lua index 8f1a68e6..5595a8f8 100644 --- a/[esx_addons]/esx_jobs/server/main.lua +++ b/[esx_addons]/esx_jobs/server/main.lua @@ -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) diff --git a/[esx_addons]/esx_policejob/client/main.lua b/[esx_addons]/esx_policejob/client/main.lua index 01874bef..26ffe26c 100644 --- a/[esx_addons]/esx_policejob/client/main.lua +++ b/[esx_addons]/esx_policejob/client/main.lua @@ -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 diff --git a/[esx_addons]/esx_policejob/config.lua b/[esx_addons]/esx_policejob/config.lua index dfea1f88..4996e7bb 100644 --- a/[esx_addons]/esx_policejob/config.lua +++ b/[esx_addons]/esx_policejob/config.lua @@ -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.