Skip to content

Commit

Permalink
refactor: (bpt_unicornjob) await callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpredator committed Mar 26, 2024
1 parent cbb79f6 commit e14b4a0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
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 @@ -259,7 +256,7 @@ function IsInAuthorizedVehicle()
return false
end

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

AddEventHandler("bpt_unicornjob:hasExitedMarker", function()
RegisterNetEvent("bpt_unicornjob: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_unicornjob:SpawnVehicle", function(source, cb, m
cb()
end)

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

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -703,4 +703,4 @@ ESX.RegisterCommand("players", "admin", function()
local xPlayer = xPlayers[i]
print(("^1[^2ID: ^5%s^0 | ^2Name : ^5%s^0 | ^2Group : ^5%s^0 | ^2Identifier : ^5%s^1]^0\n"):format(xPlayer.source, xPlayer.getName(), xPlayer.getGroup(), xPlayer.identifier))
end
end, true)
end, true)

0 comments on commit e14b4a0

Please sign in to comment.