Skip to content

Commit

Permalink
refactor: (bpt_deliveries) await callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpredator committed Mar 25, 2024
1 parent 70fe59d commit 7bfa678
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -949,16 +949,16 @@ RegisterNetEvent("esx:setJob")
RegisterNetEvent("bpt_deliveries:setPlayerJob:client")
RegisterNetEvent("bpt_deliveries:startJob:client")

AddEventHandler("esx:setJob", function(job)
RegisterNetEvent("esx:setJob", function(job)
PlayerJob = job.name
end)

AddEventHandler("bpt_deliveries:setPlayerJob:client", function(job)
RegisterNetEvent("bpt_deliveries:setPlayerJob:client", function(job)
print("Player job: " .. job)
PlayerJob = job
end)

AddEventHandler("bpt_deliveries:startJob:client", function(deliveryType)
RegisterNetEvent("bpt_deliveries:startJob:client", function(deliveryType)
TriggerEvent("MpGameMessage:send", _U("delivery_start"), _U("delivery_tips"), 3500, "success")
LoadWorkPlayerSkin(deliveryType)
local ModelHash = GetHashKey("prop_paper_bag_01")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RegisterServerEvent("bpt_deliveries:removeSafeMoney:server")
RegisterServerEvent("bpt_deliveries:getPlayerJob:server")

-- Return safe deposit event
AddEventHandler("bpt_deliveries:returnSafe:server", function(deliveryType, safeReturn)
RegisterNetEvent("bpt_deliveries:returnSafe:server", function(deliveryType, safeReturn)
local xPlayer = ESX.GetPlayerFromId(source)
if safeReturn then
local SafeMoney = 4000
Expand All @@ -25,7 +25,7 @@ AddEventHandler("bpt_deliveries:returnSafe:server", function(deliveryType, safeR
end)

-- Finish delivery mission event
AddEventHandler("bpt_deliveries:finishDelivery:server", function(deliveryType)
RegisterNetEvent("bpt_deliveries:finishDelivery:server", function(deliveryType)
local xPlayer = ESX.GetPlayerFromId(source)
local deliveryMoney = 800
for k, v in pairs(Config.Rewards) do
Expand All @@ -39,7 +39,7 @@ AddEventHandler("bpt_deliveries:finishDelivery:server", function(deliveryType)
end)

-- Remove safe deposit event (On start mission)
AddEventHandler("bpt_deliveries:removeSafeMoney:server", function(deliveryType)
RegisterNetEvent("bpt_deliveries:removeSafeMoney:server", function(deliveryType)
local xPlayer = ESX.GetPlayerFromId(source)
local SafeMoney = 4000
for k, v in pairs(Config.Safe) do
Expand All @@ -59,7 +59,7 @@ AddEventHandler("bpt_deliveries:removeSafeMoney:server", function(deliveryType)
end)

-- Get the player job name
AddEventHandler("bpt_deliveries:getPlayerJob:server", function()
RegisterNetEvent("bpt_deliveries:getPlayerJob:server", function()
local xPlayer = ESX.GetPlayerFromId(source)
print("Player request job: " .. source .. ", " .. xPlayer.job.name)
TriggerClientEvent("bpt_deliveries:setPlayerJob:client", source, xPlayer.job.name)
Expand Down

0 comments on commit 7bfa678

Please sign in to comment.