Job check

When i use if ESX.PlayerData.job == "something" for make job markers i should restart resource for show markers every time i enter server or change my job from some job to this job

How can fix this?

Can we see some of the source code where you load the ESX object and PlayerData?

ESX = nil

local PlayerData = {}

Citizen.CreateThread(function()

    while ESX == nil do

        TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)

        Citizen.Wait(0)

    end

    

    while ESX.GetPlayerData().job == nil do

        print("ESX.GetPlayerData().job = nil, waiting until not nil..")

        Citizen.Wait(100)

    end

    if ESX.GetPlayerData().job.name ~= nil then

        currentPlayerJobName = ESX.GetPlayerData().job.name

    else

        print("^1ESX.GetPlayerData().job.name == nil Cannot set job name!")

    end

    PlayerData = ESX.GetPlayerData()
end)

Try do like this:

ESX = nil
local PlayerData = {}

Citizen.CreateThread(function()
	while ESX == nil do
		TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
		Citizen.Wait(0)
	end
	while ESX.GetPlayerData() == nil do
		Citizen.Wait(10)
	end
	PlayerData = ESX.GetPlayerData()
end)

RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
    PlayerData.job = job
end)

This will load the PlayerData properly. Also allows you to switch job while resource is running without having to relog/restart the script, as the event updates the PlayerData immediately upon job update.

Then when comparing job, you can simply go ahead like this:

if PlayerData.job ~= nil and PlayerData.job.name == 'police' then
	-- code goes here...
end

thank you but i still should restart resource when i come to the server for show markers
(setjob fixed)

Can we see the source code used to interact with markers?

Citizen.CreateThread(function()

 while true do
    Citizen.Wait(0)
    if PlayerData.job ~= nil and PlayerData.job.name == 'ff' then
        local coords = GetEntityCoords(PlayerPedId())
        if GetDistanceBetweenCoords(coords, position.x, position.y, position.z, true) < 20.0 then
   cMarker(27, position, scale, color, false, true)
        end
        if GetDistanceBetweenCoords(coords, position2.x, position2.y, position2.z, true) < 20.0 then
   cMarker(27, position2, scale2, color2, false, true)
        end
        if GetDistanceBetweenCoords(coords, position3.x, position3.y, position3.z, true) < 20.0 then
   cMarker(20, position3, scale3, color3, true, false)
        end
        if GetDistanceBetweenCoords(coords, position4.x, position4.y, position4.z, true) < 20.0 then
   cMarker(36, position4, scale4, color4, true, false)
        end
        if GetDistanceBetweenCoords(coords, position5.x, position5.y, position5.z, true) < 80.0 and IsPedInAnyVehicle(PlayerPedId()) then
   cMarker(1, position5, scale5, color5, false, false)
        end
        if GetDistanceBetweenCoords(coords, position6.x, position6.y, position6.z, true) < 20.0 then
   cMarker(27, position6, scale6, color6, false, true)
        end
        if GetDistanceBetweenCoords(coords, position7.x, position7.y, position7.z, true) < 20.0 then
   cMarker(27, position7, scale7, color7, false, true)
        end
    end
 end
end)

Where is you position coords stored and what does the cMarker function do exactly?

EDIT:
For cleaner code, you should consider to create a loop to go through the different positions instead of making 20 if statements. Makes it much easier for you as well by keeping it config based.

i gonna do this but now i just want to this work

and position coords is there
after this :

Citizen.CreateThread(function()
	while ESX == nil do
		TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
		Citizen.Wait(0)
	end
	while ESX.GetPlayerData() == nil do
		Citizen.Wait(10)
	end
	PlayerData = ESX.GetPlayerData()
end)

RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
    PlayerData.job = job
end)

and cMarker make markers

Sorry, can not really help you when you are not showing the necessary functions etc. for us to see what’s going on.

im sorry you didn’t say show code
so this is cMarker :

function cMarker(type, position, scale, color, facecamera, rotate)
    if facecamera == nil then facecamera = false end
    if rotate == nil then rotate = false end
    coord = vector3(position.x, position.y, position.z)
DrawMarker(
	type, 
	coord,
    0.0,
    0.0,
    0.0,
	0.0, 
	0.0, 
	0.0, 
	scale.a, 
	scale.b, 
	scale.c, 
	color.r, 
	color.g, 
	color.b, 
	150, 
	false, 
    facecamera,
    2,
	rotate
)
end

and this is Positions :

local position, position2, position3, position4, position5, position6, position7 = vector3(190.94, -903.50, 30.81), vector3(177.20, -905.40, 30.81), vector3(181.14, -905.04, 31.10), vector3(174.0, -913.0, 30.40), vector3(162.61, -881.0, 29.40), vector3(179.40, -908.25, 30.81), vector3(187.74, -904.50, 30.81)