Skip to content

Commit

Permalink
refactor: (bpt_ballasjob) await callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpredator committed Mar 25, 2024
1 parent 4b783db commit 01117cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
13 changes: 5 additions & 8 deletions server-data/resources/[bpt_addons]/bpt_ballasjob/client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@ local HasAlreadyEnteredMarker
local CurrentAction, CurrentActionMsg = 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)

Expand Down Expand Up @@ -120,15 +117,15 @@ function OpenMobileBallasActionsMenu()
end)
end

AddEventHandler("bpt_ballasjob:hasEnteredMarker", function(zone)
RegisterNetEvent("bpt_ballasjob:hasEnteredMarker", function(zone)
if zone == "BallasActions" then
CurrentAction = "ballas_actions_menu"
CurrentActionMsg = _U("press_to_open")
CurrentActionData = {}
end
end)

AddEventHandler("bpt_ballasjob:hasExitedMarker", function()
RegisterNetEvent("bpt_ballasjob:hasExitedMarker", function()
ESX.CloseContext()
CurrentAction = nil
end)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ ESX.RegisterServerCallback("bpt_ballasjob:getPlayerInventory", function(source,
})
end)

RegisterNetEvent("bpt_ballasjob:getStockItem")
AddEventHandler("bpt_ballasjob:getStockItem", function(itemName, count)
RegisterNetEvent("bpt_ballasjob:getStockItem", function(itemName, count)
local xPlayer = ESX.GetPlayerFromId(source)

if xPlayer.job.name == "ballas" then
Expand Down Expand Up @@ -44,8 +43,7 @@ ESX.RegisterServerCallback("bpt_ballasjob:getStockItems", function(_, cb)
end)
end)

RegisterNetEvent("bpt_ballasjob:putStockItems")
AddEventHandler("bpt_ballasjob:putStockItems", function(itemName, count)
RegisterNetEvent("bpt_ballasjob:putStockItems", function(itemName, count)
local xPlayer = ESX.GetPlayerFromId(source)
local sourceItem = xPlayer.getInventoryItem(itemName)

Expand Down

0 comments on commit 01117cc

Please sign in to comment.