From ce902d5b51b3bab1091fc26e0d75bfaf913d144f Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Tue, 26 Mar 2024 01:02:35 +0100 Subject: [PATCH] refactor: (bpt_ammujob) await callbacks --- .../[bpt_addons]/bpt_importjob/client/main.lua | 13 +++++-------- .../[bpt_addons]/bpt_importjob/server/main.lua | 6 ++---- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/server-data/resources/[bpt_addons]/bpt_importjob/client/main.lua b/server-data/resources/[bpt_addons]/bpt_importjob/client/main.lua index 0b294ae78..3b0a0e3c3 100644 --- a/server-data/resources/[bpt_addons]/bpt_importjob/client/main.lua +++ b/server-data/resources/[bpt_addons]/bpt_importjob/client/main.lua @@ -2,20 +2,17 @@ local HasAlreadyEnteredMarker local CurrentAction, CurrentActionMsg, CurrentActionData = nil, "", {} local LastZone -RegisterNetEvent("esx:playerLoaded") -AddEventHandler("esx:playerLoaded", function(xPlayer) +RegisterNetEvent("esx:playerLoaded", function(xPlayer) ESX.PlayerData = xPlayer ESX.PlayerLoaded = true end) -RegisterNetEvent("esx:onPlayerLogout") -AddEventHandler("esx:onPlayerLogout", function() +RegisterNetEvent("esx:onPlayerLogout", function() ESX.PlayerLoaded = false ESX.PlayerData = {} end) -RegisterNetEvent("esx:setJob") -AddEventHandler("esx:setJob", function(job) +RegisterNetEvent("esx:setJob", function(job) ESX.PlayerData.job = job end) @@ -259,7 +256,7 @@ function IsInAuthorizedVehicle() return false end -AddEventHandler("bpt_importjob:hasEnteredMarker", function(zone) +RegisterNetEvent("bpt_importjob:hasEnteredMarker", function(zone) if zone == "VehicleSpawner" then CurrentAction = "vehicle_spawner" CurrentActionMsg = _U("spawner_prompt") @@ -286,7 +283,7 @@ AddEventHandler("bpt_importjob:hasEnteredMarker", function(zone) end end) -AddEventHandler("bpt_importjob:hasExitedMarker", function() +RegisterNetEvent("bpt_importjob:hasExitedMarker", function() ESX.CloseContext() CurrentAction = nil end) diff --git a/server-data/resources/[bpt_addons]/bpt_importjob/server/main.lua b/server-data/resources/[bpt_addons]/bpt_importjob/server/main.lua index 2251a4e9b..6490236bf 100644 --- a/server-data/resources/[bpt_addons]/bpt_importjob/server/main.lua +++ b/server-data/resources/[bpt_addons]/bpt_importjob/server/main.lua @@ -28,8 +28,7 @@ ESX.RegisterServerCallback("bpt_importjob:SpawnVehicle", function(source, cb, mo cb() end) -RegisterNetEvent("bpt_importjob:getStockItem") -AddEventHandler("bpt_importjob:getStockItem", function(itemName, count) +RegisterNetEvent("bpt_importjob:getStockItem", function(itemName, count) local xPlayer = ESX.GetPlayerFromId(source) if xPlayer.job.name == "import" then @@ -61,8 +60,7 @@ ESX.RegisterServerCallback("bpt_importjob:getStockItems", function(_, cb) end) end) -RegisterNetEvent("bpt_importjob:putStockItems") -AddEventHandler("bpt_importjob:putStockItems", function(itemName, count) +RegisterNetEvent("bpt_importjob:putStockItems", function(itemName, count) local xPlayer = ESX.GetPlayerFromId(source) local sourceItem = xPlayer.getInventoryItem(itemName)