Skip to content

Commit

Permalink
refactor: (bpt_fisherman) await callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpredator committed Mar 25, 2024
1 parent b52932b commit c4be28e
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_fisherman/client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -255,7 +252,7 @@ function IsInAuthorizedVehicle()
return false
end

AddEventHandler("bpt_fishermanjob:hasEnteredMarker", function(zone)
RegisterNetEvent("bpt_fishermanjob:hasEnteredMarker", function(zone)
if zone == "VehicleSpawner" then
CurrentAction = "vehicle_spawner"
CurrentActionMsg = _U("spawner_prompt")
Expand All @@ -282,7 +279,7 @@ AddEventHandler("bpt_fishermanjob:hasEnteredMarker", function(zone)
end
end)

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

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

if xPlayer.job.name == "fisherman" then
Expand Down Expand Up @@ -69,8 +68,7 @@ ESX.RegisterServerCallback("bpt_fishermanjob:getStockItems", function(_, cb)
end)
end)

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

Expand Down

0 comments on commit c4be28e

Please sign in to comment.