Hello, so when iam go to the armory marker to choose the gun when i leave the marker event the menu doesnt close and i can open the menu everywhere in the map, anyone can help me?
If you need screenshorts feel free .
https://github.com/snyx95/fxserver-esx_policejob there is the mod iam using.
My code on client.lua:
– Enter / Exit marker events
Citizen.CreateThread(function()
while true do
Wait(0)
if PlayerData.job ~= nil and PlayerData.job.name == 'police' then
local playerPed = GetPlayerPed(-1)
local coords = GetEntityCoords(playerPed)
local isInMarker = false
local currentStation = nil
local currentPart = nil
local currentPartNum = nil
for k,v in pairs(Config.PoliceStations) do
for i=1, #v.Cloakrooms, 1 do
if GetDistanceBetweenCoords(coords, v.Cloakrooms[i].x, v.Cloakrooms[i].y, v.Cloakrooms[i].z, true) < Config.MarkerSize.x then
isInMarker = true
currentStation = k
currentPart = 'Cloakroom'
currentPartNum = i
end
end
for i=1, #v.Armories, 1 do
if GetDistanceBetweenCoords(coords, v.Armories[i].x, v.Armories[i].y, v.Armories[i].z, true) < Config.MarkerSize.x then
isInMarker = true
currentStation = k
currentPart = 'Armory'
currentPartNum = i
end
end
for i=1, #v.Vehicles, 1 do
if GetDistanceBetweenCoords(coords, v.Vehicles[i].Spawner.x, v.Vehicles[i].Spawner.y, v.Vehicles[i].Spawner.z, true) < Config.MarkerSize.x then
isInMarker = true
currentStation = k
currentPart = 'VehicleSpawner'
currentPartNum = i
end
if GetDistanceBetweenCoords(coords, v.Vehicles[i].SpawnPoint.x, v.Vehicles[i].SpawnPoint.y, v.Vehicles[i].SpawnPoint.z, true) < Config.MarkerSize.x then
isInMarker = true
currentStation = k
currentPart = 'VehicleSpawnPoint'
currentPartNum = i
end
end
for i=1, #v.Helicopters, 1 do
if GetDistanceBetweenCoords(coords, v.Helicopters[i].Spawner.x, v.Helicopters[i].Spawner.y, v.Helicopters[i].Spawner.z, true) < Config.MarkerSize.x then
isInMarker = true
currentStation = k
currentPart = 'HelicopterSpawner'
currentPartNum = i
end
if GetDistanceBetweenCoords(coords, v.Helicopters[i].SpawnPoint.x, v.Helicopters[i].SpawnPoint.y, v.Helicopters[i].SpawnPoint.z, true) < Config.MarkerSize.x then
isInMarker = true
currentStation = k
currentPart = 'HelicopterSpawnPoint'
currentPartNum = i
end
end
for i=1, #v.VehicleDeleters, 1 do
if GetDistanceBetweenCoords(coords, v.VehicleDeleters[i].x, v.VehicleDeleters[i].y, v.VehicleDeleters[i].z, true) < Config.MarkerSize.x then
isInMarker = true
currentStation = k
currentPart = 'VehicleDeleter'
currentPartNum = i
end
end
if Config.EnablePlayerManagement and PlayerData.job ~= nil and PlayerData.job.name == 'police' and PlayerData.job.grade_name == 'boss' then
for i=1, #v.BossActions, 1 do
if GetDistanceBetweenCoords(coords, v.BossActions[i].x, v.BossActions[i].y, v.BossActions[i].z, true) < Config.MarkerSize.x then
isInMarker = true
currentStation = k
currentPart = 'BossActions'
currentPartNum = i
end
end
end
end
local hasExited = false
if isInMarker and not HasAlreadyEnteredMarker or (isInMarker and (LastStation ~= currentStation or LastPart ~= currentPart or LastPartNum ~= currentPartNum) ) then
if
(LastStation ~= nil and LastPart ~= nil and LastPartNum ~= nil) and
(LastStation ~= currentStation or LastPart ~= currentPart or LastPartNum ~= currentPartNum)
then
TriggerEvent('esx_policejob:hasExitedMarker', LastStation, LastPart, LastPartNum)
hasExited = true
end
HasAlreadyEnteredMarker = true
LastStation = currentStation
LastPart = currentPart
LastPartNum = currentPartNum
TriggerEvent('esx_policejob:hasEnteredMarker', currentStation, currentPart, currentPartNum)
end
if not hasExited and not isInMarker and HasAlreadyEnteredMarker then
HasAlreadyEnteredMarker = false
TriggerEvent('esx_policejob:hasExitedMarker', LastStation, LastPart, LastPartNum)
end
end
end
end)