From 931cd134dcd878374a5007f05127f4a2af6fc449 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Wed, 10 Apr 2024 16:18:24 +0200 Subject: [PATCH] =?UTF-8?q?chore:=20(esx=5Fmechnicjob)=20=F0=9F=8E=A8=20Ru?= =?UTF-8?q?n=20formatter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../esx_mechanicjob/client/main.lua | 6 +- .../esx_mechanicjob/server/main.lua | 202 +++++++++--------- 2 files changed, 99 insertions(+), 109 deletions(-) diff --git a/server-data/resources/[esx_addons]/esx_mechanicjob/client/main.lua b/server-data/resources/[esx_addons]/esx_mechanicjob/client/main.lua index 6edbb1c2e..fc3268128 100644 --- a/server-data/resources/[esx_addons]/esx_mechanicjob/client/main.lua +++ b/server-data/resources/[esx_addons]/esx_mechanicjob/client/main.lua @@ -47,8 +47,6 @@ function StopNPCJob(cancel) if cancel then ESX.ShowNotification(TranslateCap('mission_canceled'), "error") - else - --TriggerServerEvent('esx_mechanicjob:onNPCJobCompleted') end end @@ -65,7 +63,7 @@ function OpenMechanicActionsMenu() if Config.EnablePlayerManagement and ESX.PlayerData.job and ESX.PlayerData.job.grade_name == 'boss' then elements[#elements+1] = { icon = 'fas fa-boss', - title = TranslateCap('boss_actions'), + title = TranslateCap('boss_actions'), value = 'boss_actions' } end @@ -109,7 +107,7 @@ function OpenMechanicActionsMenu() if Config.EnablePlayerManagement and ESX.PlayerData.job and (ESX.PlayerData.job.grade_name == 'boss' or ESX.PlayerData.job.grade_name == 'chief' or ESX.PlayerData.job.grade_name == 'experimente') then elements2[#elements2+1] = { icon = 'fas fa-truck', - title = 'Slamvan', + title = 'Slamvan', value = 'slamvan3' } end diff --git a/server-data/resources/[esx_addons]/esx_mechanicjob/server/main.lua b/server-data/resources/[esx_addons]/esx_mechanicjob/server/main.lua index 4f8db9667..abd66bc76 100644 --- a/server-data/resources/[esx_addons]/esx_mechanicjob/server/main.lua +++ b/server-data/resources/[esx_addons]/esx_mechanicjob/server/main.lua @@ -1,288 +1,280 @@ -local PlayersHarvesting, PlayersHarvesting2, PlayersHarvesting3, PlayersCrafting, PlayersCrafting2, PlayersCrafting3 = {}, {}, {}, {}, {}, {} +local PlayersHarvesting, PlayersHarvesting2, PlayersHarvesting3, PlayersCrafting, PlayersCrafting2, PlayersCrafting3 = + {}, {}, {}, {}, {}, {} if Config.MaxInService ~= -1 then - TriggerEvent('esx_service:activateService', 'mechanic', Config.MaxInService) + TriggerEvent("esx_service:activateService", "mechanic", Config.MaxInService) end -TriggerEvent('esx_phone:registerNumber', 'mechanic', TranslateCap('mechanic_customer'), true, true) -TriggerEvent('esx_society:registerSociety', 'mechanic', 'mechanic', 'society_mechanic', 'society_mechanic', 'society_mechanic', {type = 'private'}) +TriggerEvent("esx_phone:registerNumber", "mechanic", TranslateCap("mechanic_customer"), true, true) +TriggerEvent("esx_society:registerSociety", "mechanic", "mechanic", "society_mechanic", "society_mechanic", "society_mechanic", + { + type = "private" + } +) local function Harvest(source) SetTimeout(4000, function() - if PlayersHarvesting[source] == true then local xPlayer = ESX.GetPlayerFromId(source) - local GazBottleQuantity = xPlayer.getInventoryItem('gazbottle').count + local GazBottleQuantity = xPlayer.getInventoryItem("gazbottle").count if GazBottleQuantity >= 5 then - TriggerClientEvent('esx:showNotification', source, TranslateCap('you_do_not_room')) + TriggerClientEvent("esx:showNotification", source, TranslateCap("you_do_not_room")) else - xPlayer.addInventoryItem('gazbottle', 1) + xPlayer.addInventoryItem("gazbottle", 1) Harvest(source) end end - end) end -RegisterServerEvent('esx_mechanicjob:startHarvest') -AddEventHandler('esx_mechanicjob:startHarvest', function() +RegisterServerEvent("esx_mechanicjob:startHarvest") +AddEventHandler("esx_mechanicjob:startHarvest", function() local source = source PlayersHarvesting[source] = true - TriggerClientEvent('esx:showNotification', source, TranslateCap('recovery_gas_can')) + TriggerClientEvent("esx:showNotification", source, TranslateCap("recovery_gas_can")) Harvest(source) end) -RegisterServerEvent('esx_mechanicjob:stopHarvest') -AddEventHandler('esx_mechanicjob:stopHarvest', function() +RegisterServerEvent("esx_mechanicjob:stopHarvest") +AddEventHandler("esx_mechanicjob:stopHarvest", function() local source = source PlayersHarvesting[source] = false end) local function Harvest2(source) SetTimeout(4000, function() - if PlayersHarvesting2[source] == true then local xPlayer = ESX.GetPlayerFromId(source) - local FixToolQuantity = xPlayer.getInventoryItem('fixtool').count + local FixToolQuantity = xPlayer.getInventoryItem("fixtool").count if FixToolQuantity >= 5 then - TriggerClientEvent('esx:showNotification', source, TranslateCap('you_do_not_room')) + TriggerClientEvent("esx:showNotification", source, TranslateCap("you_do_not_room")) else - xPlayer.addInventoryItem('fixtool', 1) + xPlayer.addInventoryItem("fixtool", 1) Harvest2(source) end end - end) end -RegisterServerEvent('esx_mechanicjob:startHarvest2') -AddEventHandler('esx_mechanicjob:startHarvest2', function() +RegisterServerEvent("esx_mechanicjob:startHarvest2") +AddEventHandler("esx_mechanicjob:startHarvest2", function() local source = source PlayersHarvesting2[source] = true - TriggerClientEvent('esx:showNotification', source, TranslateCap('recovery_repair_tools')) + TriggerClientEvent("esx:showNotification", source, TranslateCap("recovery_repair_tools")) Harvest2(source) end) -RegisterServerEvent('esx_mechanicjob:stopHarvest2') -AddEventHandler('esx_mechanicjob:stopHarvest2', function() +RegisterServerEvent("esx_mechanicjob:stopHarvest2") +AddEventHandler("esx_mechanicjob:stopHarvest2", function() local source = source PlayersHarvesting2[source] = false end) local function Harvest3(source) SetTimeout(4000, function() - if PlayersHarvesting3[source] == true then local xPlayer = ESX.GetPlayerFromId(source) - local CaroToolQuantity = xPlayer.getInventoryItem('carotool').count + local CaroToolQuantity = xPlayer.getInventoryItem("carotool").count if CaroToolQuantity >= 5 then - TriggerClientEvent('esx:showNotification', source, TranslateCap('you_do_not_room')) + TriggerClientEvent("esx:showNotification", source, TranslateCap("you_do_not_room")) else - xPlayer.addInventoryItem('carotool', 1) + xPlayer.addInventoryItem("carotool", 1) Harvest3(source) end end - end) end -RegisterServerEvent('esx_mechanicjob:startHarvest3') -AddEventHandler('esx_mechanicjob:startHarvest3', function() +RegisterServerEvent("esx_mechanicjob:startHarvest3") +AddEventHandler("esx_mechanicjob:startHarvest3", function() local source = source PlayersHarvesting3[source] = true - TriggerClientEvent('esx:showNotification', source, TranslateCap('recovery_body_tools')) + TriggerClientEvent("esx:showNotification", source, TranslateCap("recovery_body_tools")) Harvest3(source) end) -RegisterServerEvent('esx_mechanicjob:stopHarvest3') -AddEventHandler('esx_mechanicjob:stopHarvest3', function() +RegisterServerEvent("esx_mechanicjob:stopHarvest3") +AddEventHandler("esx_mechanicjob:stopHarvest3", function() local source = source PlayersHarvesting3[source] = false end) local function Craft(source) SetTimeout(4000, function() - if PlayersCrafting[source] == true then local xPlayer = ESX.GetPlayerFromId(source) - local GazBottleQuantity = xPlayer.getInventoryItem('gazbottle').count + local GazBottleQuantity = xPlayer.getInventoryItem("gazbottle").count if GazBottleQuantity <= 0 then - TriggerClientEvent('esx:showNotification', source, TranslateCap('not_enough_gas_can')) + TriggerClientEvent("esx:showNotification", source, TranslateCap("not_enough_gas_can")) else - xPlayer.removeInventoryItem('gazbottle', 1) - xPlayer.addInventoryItem('blowpipe', 1) + xPlayer.removeInventoryItem("gazbottle", 1) + xPlayer.addInventoryItem("blowpipe", 1) Craft(source) end end - end) end -RegisterServerEvent('esx_mechanicjob:startCraft') -AddEventHandler('esx_mechanicjob:startCraft', function() +RegisterServerEvent("esx_mechanicjob:startCraft") +AddEventHandler("esx_mechanicjob:startCraft", function() local source = source PlayersCrafting[source] = true - TriggerClientEvent('esx:showNotification', source, TranslateCap('assembling_blowtorch')) + TriggerClientEvent("esx:showNotification", source, TranslateCap("assembling_blowtorch")) Craft(source) end) -RegisterServerEvent('esx_mechanicjob:stopCraft') -AddEventHandler('esx_mechanicjob:stopCraft', function() +RegisterServerEvent("esx_mechanicjob:stopCraft") +AddEventHandler("esx_mechanicjob:stopCraft", function() local source = source PlayersCrafting[source] = false end) local function Craft2(source) SetTimeout(4000, function() - if PlayersCrafting2[source] == true then local xPlayer = ESX.GetPlayerFromId(source) - local FixToolQuantity = xPlayer.getInventoryItem('fixtool').count + local FixToolQuantity = xPlayer.getInventoryItem("fixtool").count if FixToolQuantity <= 0 then - TriggerClientEvent('esx:showNotification', source, TranslateCap('not_enough_repair_tools')) + TriggerClientEvent("esx:showNotification", source, TranslateCap("not_enough_repair_tools")) else - xPlayer.removeInventoryItem('fixtool', 1) - xPlayer.addInventoryItem('fixkit', 1) + xPlayer.removeInventoryItem("fixtool", 1) + xPlayer.addInventoryItem("fixkit", 1) Craft2(source) end end - end) end -RegisterServerEvent('esx_mechanicjob:startCraft2') -AddEventHandler('esx_mechanicjob:startCraft2', function() +RegisterServerEvent("esx_mechanicjob:startCraft2") +AddEventHandler("esx_mechanicjob:startCraft2", function() local source = source PlayersCrafting2[source] = true - TriggerClientEvent('esx:showNotification', source, TranslateCap('assembling_repair_kit')) + TriggerClientEvent("esx:showNotification", source, TranslateCap("assembling_repair_kit")) Craft2(source) end) -RegisterServerEvent('esx_mechanicjob:stopCraft2') -AddEventHandler('esx_mechanicjob:stopCraft2', function() +RegisterServerEvent("esx_mechanicjob:stopCraft2") +AddEventHandler("esx_mechanicjob:stopCraft2", function() local source = source PlayersCrafting2[source] = false end) local function Craft3(source) SetTimeout(4000, function() - if PlayersCrafting3[source] == true then local xPlayer = ESX.GetPlayerFromId(source) - local CaroToolQuantity = xPlayer.getInventoryItem('carotool').count + local CaroToolQuantity = xPlayer.getInventoryItem("carotool").count if CaroToolQuantity <= 0 then - TriggerClientEvent('esx:showNotification', source, TranslateCap('not_enough_body_tools')) + TriggerClientEvent("esx:showNotification", source, TranslateCap("not_enough_body_tools")) else - xPlayer.removeInventoryItem('carotool', 1) - xPlayer.addInventoryItem('carokit', 1) + xPlayer.removeInventoryItem("carotool", 1) + xPlayer.addInventoryItem("carokit", 1) Craft3(source) end end - end) end -RegisterServerEvent('esx_mechanicjob:startCraft3') -AddEventHandler('esx_mechanicjob:startCraft3', function() +RegisterServerEvent("esx_mechanicjob:startCraft3") +AddEventHandler("esx_mechanicjob:startCraft3", function() local source = source PlayersCrafting3[source] = true - TriggerClientEvent('esx:showNotification', source, TranslateCap('assembling_body_kit')) + TriggerClientEvent("esx:showNotification", source, TranslateCap("assembling_body_kit")) Craft3(source) end) -RegisterServerEvent('esx_mechanicjob:stopCraft3') -AddEventHandler('esx_mechanicjob:stopCraft3', function() +RegisterServerEvent("esx_mechanicjob:stopCraft3") +AddEventHandler("esx_mechanicjob:stopCraft3", function() local source = source PlayersCrafting3[source] = false end) -RegisterServerEvent('esx_mechanicjob:onNPCJobMissionCompleted') -AddEventHandler('esx_mechanicjob:onNPCJobMissionCompleted', function() +RegisterServerEvent("esx_mechanicjob:onNPCJobMissionCompleted") +AddEventHandler("esx_mechanicjob:onNPCJobMissionCompleted", function() local source = source local xPlayer = ESX.GetPlayerFromId(source) - local total = math.random(Config.NPCJobEarnings.min, Config.NPCJobEarnings.max); + local total = math.random(Config.NPCJobEarnings.min, Config.NPCJobEarnings.max) if xPlayer.job.grade >= 3 then total = total * 2 end - TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mechanic', function(account) + TriggerEvent("esx_addonaccount:getSharedAccount", "society_mechanic", function(account) account.addMoney(total) end) - TriggerClientEvent("esx:showNotification", source, TranslateCap('your_comp_earned').. total) + TriggerClientEvent("esx:showNotification", source, TranslateCap("your_comp_earned") .. total) end) -ESX.RegisterUsableItem('blowpipe', function(source) +ESX.RegisterUsableItem("blowpipe", function(source) local source = source - local xPlayer = ESX.GetPlayerFromId(source) + local xPlayer = ESX.GetPlayerFromId(source) - xPlayer.removeInventoryItem('blowpipe', 1) + xPlayer.removeInventoryItem("blowpipe", 1) - TriggerClientEvent('esx_mechanicjob:onHijack', source) - TriggerClientEvent('esx:showNotification', source, TranslateCap('you_used_blowtorch')) + TriggerClientEvent("esx_mechanicjob:onHijack", source) + TriggerClientEvent("esx:showNotification", source, TranslateCap("you_used_blowtorch")) end) -ESX.RegisterUsableItem('fixkit', function(source) +ESX.RegisterUsableItem("fixkit", function(source) local source = source - local xPlayer = ESX.GetPlayerFromId(source) + local xPlayer = ESX.GetPlayerFromId(source) - xPlayer.removeInventoryItem('fixkit', 1) + xPlayer.removeInventoryItem("fixkit", 1) - TriggerClientEvent('esx_mechanicjob:onFixkit', source) - TriggerClientEvent('esx:showNotification', source, TranslateCap('you_used_repair_kit')) + TriggerClientEvent("esx_mechanicjob:onFixkit", source) + TriggerClientEvent("esx:showNotification", source, TranslateCap("you_used_repair_kit")) end) -ESX.RegisterUsableItem('carokit', function(source) +ESX.RegisterUsableItem("carokit", function(source) local source = source - local xPlayer = ESX.GetPlayerFromId(source) + local xPlayer = ESX.GetPlayerFromId(source) - xPlayer.removeInventoryItem('carokit', 1) + xPlayer.removeInventoryItem("carokit", 1) - TriggerClientEvent('esx_mechanicjob:onCarokit', source) - TriggerClientEvent('esx:showNotification', source, TranslateCap('you_used_body_kit')) + TriggerClientEvent("esx_mechanicjob:onCarokit", source) + TriggerClientEvent("esx:showNotification", source, TranslateCap("you_used_body_kit")) end) -RegisterServerEvent('esx_mechanicjob:getStockItem') -AddEventHandler('esx_mechanicjob:getStockItem', function(itemName, count) +RegisterServerEvent("esx_mechanicjob:getStockItem") +AddEventHandler("esx_mechanicjob:getStockItem", function(itemName, count) local xPlayer = ESX.GetPlayerFromId(source) - TriggerEvent('esx_addoninventory:getSharedInventory', 'society_mechanic', function(inventory) + TriggerEvent("esx_addoninventory:getSharedInventory", "society_mechanic", function(inventory) local item = inventory.getItem(itemName) -- is there enough in the society? if count > 0 and item.count >= count then - -- can the player carry the said amount of x item? if xPlayer.canCarryItem(itemName, count) then inventory.removeItem(itemName, count) xPlayer.addInventoryItem(itemName, count) - xPlayer.showNotification(TranslateCap('have_withdrawn', count, item.label)) + xPlayer.showNotification(TranslateCap("have_withdrawn", count, item.label)) else - xPlayer.showNotification(TranslateCap('player_cannot_hold')) + xPlayer.showNotification(TranslateCap("player_cannot_hold")) end else - xPlayer.showNotification(TranslateCap('invalid_quantity')) + xPlayer.showNotification(TranslateCap("invalid_quantity")) end end) end) -ESX.RegisterServerCallback('esx_mechanicjob:getStockItems', function(source, cb) - TriggerEvent('esx_addoninventory:getSharedInventory', 'society_mechanic', function(inventory) +ESX.RegisterServerCallback("esx_mechanicjob:getStockItems", function(source, cb) + TriggerEvent("esx_addoninventory:getSharedInventory", "society_mechanic", function(inventory) cb(inventory.items) end) end) -RegisterServerEvent('esx_mechanicjob:putStockItems') -AddEventHandler('esx_mechanicjob:putStockItems', function(itemName, count) +RegisterServerEvent("esx_mechanicjob:putStockItems") +AddEventHandler("esx_mechanicjob:putStockItems", function(itemName, count) local xPlayer = ESX.GetPlayerFromId(source) - TriggerEvent('esx_addoninventory:getSharedInventory', 'society_mechanic', function(inventory) + TriggerEvent("esx_addoninventory:getSharedInventory", "society_mechanic", function(inventory) local item = inventory.getItem(itemName) local playerItemCount = xPlayer.getInventoryItem(itemName).count @@ -290,16 +282,16 @@ AddEventHandler('esx_mechanicjob:putStockItems', function(itemName, count) xPlayer.removeInventoryItem(itemName, count) inventory.addItem(itemName, count) else - xPlayer.showNotification(TranslateCap('invalid_quantity')) + xPlayer.showNotification(TranslateCap("invalid_quantity")) end - xPlayer.showNotification(TranslateCap('have_deposited', count, item.label)) + xPlayer.showNotification(TranslateCap("have_deposited", count, item.label)) end) end) -ESX.RegisterServerCallback('esx_mechanicjob:getPlayerInventory', function(source, cb) - local xPlayer = ESX.GetPlayerFromId(source) - local items = xPlayer.inventory +ESX.RegisterServerCallback("esx_mechanicjob:getPlayerInventory", function(source, cb) + local xPlayer = ESX.GetPlayerFromId(source) + local items = xPlayer.inventory - cb({items = items}) + cb({ items = items }) end)