Skip to content

Commit

Permalink
fix: (esx_policejob) accessing undefined variable
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpredator committed Apr 7, 2024
1 parent 01c383a commit fe78778
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 76 deletions.
22 changes: 11 additions & 11 deletions server-data/resources/[esx_addons]/esx_policejob/client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function OpenCloakroomMenu()
}
end

for k, v in ipairs(Config.CustomPeds[grade]) do
for _, v in ipairs(Config.CustomPeds[grade]) do
elements[#elements + 1] = {
icon = "fas fa-shirt",
title = v.label,
Expand Down Expand Up @@ -693,7 +693,7 @@ function OpenUnpaidBillsMenu(player)
}

ESX.TriggerServerCallback("esx_billing:getTargetBills", function(bills)
for k, bill in ipairs(bills) do
for _, bill in ipairs(bills) do
elements[#elements + 1] = {
unselectable = true,
icon = "fas fa-scroll",
Expand Down Expand Up @@ -788,8 +788,8 @@ function OpenBuyWeaponsMenu()
}
local playerPed = PlayerPedId()

for k, v in ipairs(Config.AuthorizedWeapons[ESX.PlayerData.job.grade_name]) do
local weaponNum, weapon = ESX.GetWeapon(v.weapon)
for _, v in ipairs(Config.AuthorizedWeapons[ESX.PlayerData.job.grade_name]) do
local _, weapon = ESX.GetWeapon(v.weapon)
local components, label = {}
local hasWeapon = HasPedGotWeapon(playerPed, joaat(v.weapon), false)

Expand Down Expand Up @@ -1092,8 +1092,7 @@ AddEventHandler("esx_policejob:hasEnteredEntityZone", function(entity)
end

if GetEntityModel(entity) == `p_ld_stinger_s` then
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)
local _ = GetEntityCoords(playerPed)

if IsPedInAnyVehicle(playerPed, false) then
local vehicle = GetVehiclePedIsIn(playerPed)
Expand Down Expand Up @@ -1327,7 +1326,7 @@ end)

-- Create blips
CreateThread(function()
for k, v in pairs(Config.PoliceStations) do
for _, v in pairs(Config.PoliceStations) do
local blip = AddBlipForCoord(v.Blip.Coords)

SetBlipSprite(blip, v.Blip.Sprite)
Expand Down Expand Up @@ -1625,9 +1624,6 @@ ESX.RegisterInput("police:interact", "(ESX PoliceJob) " .. TranslateCap("interac
return
end

if not ESX.PlayerData.job or (ESX.PlayerData.job and not ESX.PlayerData.job.name == "police") then
return
end
if CurrentAction == "menu_cloakroom" then
OpenCloakroomMenu()
elseif CurrentAction == "menu_armory" then
Expand Down Expand Up @@ -1679,6 +1675,10 @@ ESX.RegisterInput("police:interact", "(ESX PoliceJob) " .. TranslateCap("interac
DeleteEntity(CurrentActionData.entity)
end

if not ESX.PlayerData.job or (ESX.PlayerData.job and not ESX.PlayerData.job.name == "police") then
return
end

CurrentAction = nil
end)

Expand Down Expand Up @@ -1735,7 +1735,7 @@ end
RegisterNetEvent("esx_policejob:updateBlip")
AddEventHandler("esx_policejob:updateBlip", function()
-- Refresh all blips
for k, existingBlip in pairs(blipsCops) do
for _, existingBlip in pairs(blipsCops) do
RemoveBlip(existingBlip)
end

Expand Down
Loading

0 comments on commit fe78778

Please sign in to comment.