From 70fe59db9b44f50373021ede85c4f622dfa98a65 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 25 Mar 2024 20:12:21 +0100 Subject: [PATCH] refactor: (bpt_crafting) await callbacks --- .../[bpt_addons]/bpt_crafting/client/main.lua | 9 +++------ .../[bpt_addons]/bpt_crafting/server/main.lua | 12 ++++-------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/server-data/resources/[bpt_addons]/bpt_crafting/client/main.lua b/server-data/resources/[bpt_addons]/bpt_crafting/client/main.lua index 964847b44..7c973e079 100644 --- a/server-data/resources/[bpt_addons]/bpt_crafting/client/main.lua +++ b/server-data/resources/[bpt_addons]/bpt_crafting/client/main.lua @@ -97,8 +97,7 @@ CreateThread(function() end end) -RegisterNetEvent("esx:setJob") -AddEventHandler("esx:setJob", function(j) +RegisterNetEvent("esx:setJob", function(j) job = j.name grade = j.grade end) @@ -210,8 +209,7 @@ CreateThread(function() end end) -RegisterNetEvent("bpt_crafting:craftStart") -AddEventHandler("bpt_crafting:craftStart", function(item, _) +RegisterNetEvent("bpt_crafting:craftStart", function(item) local id = math.random(000, 999) table.insert(craftingQueue, { time = Config.Recipes[item].Time, item = item, count = 1, id = id }) @@ -228,8 +226,7 @@ AddEventHandler("bpt_crafting:craftStart", function(item, _) }) end) -RegisterNetEvent("bpt_crafting:sendMessage") -AddEventHandler("bpt_crafting:sendMessage", function(msg) +RegisterNetEvent("bpt_crafting:sendMessage", function(msg) SendTextMessage(msg) end) diff --git a/server-data/resources/[bpt_addons]/bpt_crafting/server/main.lua b/server-data/resources/[bpt_addons]/bpt_crafting/server/main.lua index 02fe0650b..3e57b2139 100644 --- a/server-data/resources/[bpt_addons]/bpt_crafting/server/main.lua +++ b/server-data/resources/[bpt_addons]/bpt_crafting/server/main.lua @@ -24,13 +24,11 @@ function giveCraftingLevel(identifier, level) ) end -RegisterServerEvent("bpt_crafting:setExperiance") -AddEventHandler("bpt_crafting:setExperiance", function(identifier, xp) +RegisterServerEvent("bpt_crafting:setExperiance", function(identifier, xp) setCraftingLevel(identifier, xp) end) -RegisterServerEvent("bpt_crafting:giveExperiance") -AddEventHandler("bpt_crafting:giveExperiance", function(identifier, xp) +RegisterServerEvent("bpt_crafting:giveExperiance", function(identifier, xp) giveCraftingLevel(identifier, xp) end) @@ -95,8 +93,7 @@ function craft(src, item, retrying) end end -RegisterServerEvent("bpt_crafting:itemCrafted") -AddEventHandler("bpt_crafting:itemCrafted", function(item, count) +RegisterServerEvent("bpt_crafting:itemCrafted", function(item, count) local src = source local xPlayer = ESX.GetPlayerFromId(src) @@ -134,8 +131,7 @@ AddEventHandler("bpt_crafting:itemCrafted", function(item, count) end end) -RegisterServerEvent("bpt_crafting:craft") -AddEventHandler("bpt_crafting:craft", function(item, retrying) +RegisterServerEvent("bpt_crafting:craft", function(item, retrying) local src = source craft(src, item, retrying) end)