Skip to content

Commit

Permalink
refactor: (bpt_crafting) await callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpredator committed Mar 25, 2024
1 parent 01117cc commit 70fe59d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 })

Expand All @@ -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)

Expand Down
12 changes: 4 additions & 8 deletions server-data/resources/[bpt_addons]/bpt_crafting/server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 70fe59d

Please sign in to comment.