DrawMarker works only after restarting resource

You should make sure that ESX.PlayerData.job is not nil before the next steps. I’m not sure if this is the cause but it definitely seems like it is.

Just add

while ESX.PlayerData.job == nil do
    Wait(10)
end

before your while true do in this script you’ve send a picture of. Tell me if it works for you.

main.lua (56.9 KB)
this is the file, you could do it for me because I don’t know where to put my hand

CreateThread(function()
	while not ESX.PlayerData.job do
		Wait(10)
	end
	while true do
		Wait(0)

		if ESX.PlayerData.job and ESX.PlayerData.job.name == 'police' then
			local playerPed = PlayerPedId()
			local playerCoords = GetEntityCoords(playerPed)
			local isInMarker, hasExited, letSleep = false, false, true
			local currentStation, currentPart, currentPartNum

This is top part of the code, replace it in the file.

If it throws an error then change while not ESX.PlayerData.job do to while not ESX.PlayerData do

don’t work

esx_policejob.rar (43.1 KB)
this is file