I have to restart script for make it work

Any solution for this problem?

You didn’t even say which script it is and what it does?

--- esx
local GUI = {}
ESX                           = nil
GUI.Time                      = 0
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
		Citizen.Wait(100)
	end

	PlayerLoaded = true
	ESX.PlayerData = ESX.GetPlayerData()
end)

RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)
	ESX.PlayerData = xPlayer
	PlayerLoaded = true
end)

RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
	ESX.PlayerData.job = job
	
	Citizen.Wait(5000)
	TriggerServerEvent('esx_policejob:forceBlip')
end)

AddEventHandler('playerSpawned', function(spawn)
	isDead = false

	if not hasAlreadyJoined then
		TriggerServerEvent('esx_policejob:spawned')
	end
	hasAlreadyJoined = true
end)


-- Pistola

Citizen.CreateThread(function(job)
	local location = Config.CoordPistola
	local playerCoords = GetEntityCoords(GetPlayerPed(-1))
	local playerPed = GetPlayerPed(-1)
	local ped = GetPlayerPed(-1)

    local dict = Config.AnimLib
    local anim = Config.Anim
	while true do
	Citizen.Wait(500)
		if ESX.PlayerData.job.name == 'blackmarket' then
			if isNear then
				Draw3DText(Config.CoordPistola.x, Config.CoordPistola.y, Config.CoordPistola.z, Config.Press .. Config.Pistol, 0.4)
			end
			if isNear then
				if IsControlJustReleased(0, 38) then
					RequestAnimDict(dict)
					while not HasAnimDictLoaded(dict) do
						Citizen.Wait(1)
					end
					ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(quantity)
						if quantity >= 3 then
							ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(quantity2)
								if quantity2 >= 3 then
									if not HasPedGotWeapon(ped, 0x1B06D571, false) then
										SetEntityCoords(PlayerPedId(), Config.CoordPistola.x, Config.CoordPistola.y, Config.CoordPistola.z, 0, 0, 0, 0)
										SetEntityHeading(PlayerPedId(), 120.0)
										TaskPlayAnim(ped, dict, anim, 12.0, 12.0, -1, 0, 0, 0, 40, 0)
										exports['progressBars']:startUI(5000, Config.ProgressBar)
										Citizen.Wait(5000)
										ClearPedTasks(ped)
										Citizen.Wait(100)
										TriggerServerEvent('craft:pistola')
										haveWeapon = true
									else
										exports['mythic_notify']:DoHudText('server', Config.InventoryGun)
									end
								else
									exports['mythic_notify']:DoHudText('server', Config.NoIron)
								end
							end, 'iron')
						else
							exports['mythic_notify']:DoHudText('server', Config.NoPowder)
						end
					end, 'gunpowder')
				end
			end
		end
	end
end)

-- SMG

Citizen.CreateThread(function(job)
	local location2 = Config.CoordSMG
	local playerCoords = GetEntityCoords(GetPlayerPed(-1))
	local playerPed = GetPlayerPed(-1)
	local ped = GetPlayerPed(-1)

    local dict = Config.AnimLib
    local anim = Config.Anim
	while true do
	Citizen.Wait(500)
		if ESX.PlayerData.job.name == 'blackmarket' then
			if isNear2 then
				Draw3DText(location2.x, location2.y, location2.z, Config.Press .. Config.SMG, 0.4)
			end
			if isNear2 then
				if IsControlJustReleased(0, 38) then
					RequestAnimDict(dict)
					while not HasAnimDictLoaded(dict) do
						Citizen.Wait(1)
					end
					ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(quantity)
						if quantity >= 15 then
							ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(quantity2)
								if quantity2 >= 15 then
									if not HasPedGotWeapon(ped, 0x2BE6766B, false) then
										SetEntityCoords(PlayerPedId(), Config.CoordSMG.x, Config.CoordSMG.y, Config.CoordSMG.z, 0, 0, 0, 0)
										SetEntityHeading(PlayerPedId(), 120.0)
										TaskPlayAnim(ped, dict, anim, 12.0, 12.0, -1, 0, 0, 0, 40, 0)
										exports['progressBars']:startUI(5000, Config.ProgressBar)
										Citizen.Wait(5000)
										ClearPedTasks(ped)
										Citizen.Wait(100)
										TriggerServerEvent('craft:smg')
									else
										exports['mythic_notify']:DoHudText('server', Config.InventoryGun)
									end
								else
									exports['mythic_notify']:DoHudText('server', Config.NoIron)
								end
							end, 'iron')
						else
							exports['mythic_notify']:DoHudText('server', Config.NoPowder)
						end
					end, 'gunpowder')
				end
			end
		end
	end
end)

--473.5189, -1313.204, 29.2071
 
Citizen.CreateThread(function(job)
	local location2 = Config.CoordPistol50
	local playerCoords = GetEntityCoords(GetPlayerPed(-1))
	local playerPed = GetPlayerPed(-1)
	local ped = GetPlayerPed(-1)

    local dict = Config.AnimLib
    local anim = Config.Anim
	while true do
	Citizen.Wait(500)
		if ESX.PlayerData.job.name == 'blackmarket' then
			if isNear3 then
				Draw3DText(location2.x, location2.y, location2.z, Config.Press .. Config.Pistol50, 0.4)
			end
			if isNear3 then
				if IsControlJustReleased(0, 38) then
					RequestAnimDict(dict)
					while not HasAnimDictLoaded(dict) do
						Citizen.Wait(1)
					end
					ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(quantity)
						if quantity >= 50 then
							ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(quantity2)
								if quantity2 >= 50 then
									if not HasPedGotWeapon(ped, 0x99AEEB3B, false) then
										SetEntityCoords(PlayerPedId(), Config.CoordPistol50.x, Config.CoordPistol50.y, Config.CoordPistol50.z, 0, 0, 0, 0)
										SetEntityHeading(PlayerPedId(), 250.0)
										TaskPlayAnim(ped, dict, anim, 12.0, 12.0, -1, 0, 0, 0, 40, 0)
										exports['progressBars']:startUI(5000, Config.ProgressBar)
										Citizen.Wait(5000)
										ClearPedTasks(ped)
										Citizen.Wait(100)
										TriggerServerEvent('craft:pistol50')
									else
										exports['mythic_notify']:DoHudText('server', Config.InventoryGun)
									end
								else
									exports['mythic_notify']:DoHudText('server', Config.NoIron)
								end
							end, 'iron')
						else
							exports['mythic_notify']:DoHudText('server', Config.NoPowder)
						end
					end, 'gunpowder')
				end
			end
		end
	end
end)

--247.0445, 370.7323, 104.7383

Citizen.CreateThread(function(job)
	local location2 = Config.CoordApPistol
	local playerCoords = GetEntityCoords(GetPlayerPed(-1))
	local playerPed = GetPlayerPed(-1)
	local ped = GetPlayerPed(-1)

    local dict = Config.AnimLib
    local anim = Config.Anim
	while true do
	Citizen.Wait(500)
		if ESX.PlayerData.job.name == 'blackmarket' then
			if isNear4 then
				Draw3DText(location2.x, location2.y, location2.z, Config.Press ..  Config.ApPistol, 0.4)
			end
			if isNear4 then
				if IsControlJustReleased(0, 38) then
					RequestAnimDict(dict)
					while not HasAnimDictLoaded(dict) do
						Citizen.Wait(1)
					end
					ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(quantity)
						if quantity >= 80 then
							ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(quantity2)
								if quantity2 >= 80 then
									if not HasPedGotWeapon(ped, 0x22D8FE39, false) then
										SetEntityCoords(PlayerPedId(), Config.CoordApPistol.x, Config.CoordApPistol.y, Config.CoordApPistol.z, 0, 0, 0, 0)
										SetEntityHeading(PlayerPedId(), 250.0)
										TaskPlayAnim(ped, dict, anim, 12.0, 12.0, -1, 0, 0, 0, 40, 0)
										exports['progressBars']:startUI(5000, Config.ProgressBar)
										Citizen.Wait(5000)
										ClearPedTasks(ped)
										Citizen.Wait(100)
										TriggerServerEvent('craft:appistol')
									else
										exports['mythic_notify']:DoHudText('server', Config.InventoryGun)
									end
								else
									exports['mythic_notify']:DoHudText('server', Config.NoIron)
								end
							end, 'iron')
						else
							exports['mythic_notify']:DoHudText('server', Config.NoPowder)
						end
					end, 'gunpowder')
				end
			end
		end
	end
end)

-- -56.50979, -2520.336, 6.40

Citizen.CreateThread(function(job)
	local location2 = Config.CoordShotGun
	local playerCoords = GetEntityCoords(GetPlayerPed(-1))
	local playerPed = GetPlayerPed(-1)
	local ped = GetPlayerPed(-1)

    local dict = Config.AnimLib
    local anim = Config.Anim
	while true do
	Citizen.Wait(500)
		if ESX.PlayerData.job.name == 'blackmarket' then
			if isNear5 then
				Draw3DText(location2.x, location2.y, location2.z, Config.Press ..  Config.ShotGun, 0.4)
			end
			if isNear5 then
				if IsControlJustReleased(0, 38) then
					RequestAnimDict(dict)
					while not HasAnimDictLoaded(dict) do
						Citizen.Wait(1)
					end
					ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(quantity)
						if quantity >= 100 then
							ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(quantity2)
								if quantity2 >= 100 then
									if not HasPedGotWeapon(ped, 0x1D073A89, false) then
										SetEntityCoords(PlayerPedId(), Config.CoordShotGun.y, Config.CoordShotGun.x, Config.CoordShotGun.z, 0, 0, 0, 0)
										SetEntityHeading(PlayerPedId(), 331.0)
										TaskPlayAnim(ped, dict, anim, 12.0, 12.0, -1, 0, 0, 0, 40, 0)
										exports['progressBars']:startUI(5000, Config.ProgressBar)
										Citizen.Wait(5000)
										ClearPedTasks(ped)
										Citizen.Wait(100)
										TriggerServerEvent('craft:shotgun')
									else
										exports['mythic_notify']:DoHudText('server', Config.InventoryGun)
									end
								else
									exports['mythic_notify']:DoHudText('server', Config.NoIron)
								end
							end, 'iron')
						else
							exports['mythic_notify']:DoHudText('server', Config.NoPowder)
						end
					end, 'gunpowder')
				end
			end
		end
	end
end)

Citizen.CreateThread(function(job)
	local location2 = Config.CoordAk
	local playerCoords = GetEntityCoords(GetPlayerPed(-1))
	local playerPed = GetPlayerPed(-1)
	local ped = GetPlayerPed(-1)

    local dict = Config.AnimLib
    local anim = Config.Anim
	while true do
	Citizen.Wait(500)
		if ESX.PlayerData.job.name == 'blackmarket' then
			if isNear6 then
				Draw3DText(location2.x, location2.y, location2.z, Config.Press .. Config.Ak, 0.4)
			end
			if isNear6 then
				if IsControlJustReleased(0, 38) then
					RequestAnimDict(dict)
					while not HasAnimDictLoaded(dict) do
						Citizen.Wait(1)
					end
					ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(quantity)
						if quantity >= 200 then
							ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(quantity2)
								if quantity2 >= 200 then
									if not HasPedGotWeapon(ped, 0xBFEFFF6D, false) then
										SetEntityCoords(PlayerPedId(), Config.CoordAk.x, Config.CoordAk.y, Config.CoordAk.z, 0, 0, 0, 0)
										SetEntityHeading(PlayerPedId(), 243.0)
										TaskPlayAnim(ped, dict, anim, 12.0, 12.0, -1, 0, 0, 0, 40, 0)
										exports['progressBars']:startUI(5000, Config.ProgressBar)
										Citizen.Wait(5000)
										ClearPedTasks(ped)
										Citizen.Wait(100)
										TriggerServerEvent('craft:ak')
									else
										exports['mythic_notify']:DoHudText('server', Config.InventoryGun)
									end
								else
									exports['mythic_notify']:DoHudText('server', Config.NoIron)
								end
							end, 'iron')
						else
							exports['mythic_notify']:DoHudText('server', Config.NoPowder)
						end
					end, 'gunpowder')
				end
			end
		end
	end
end)

Citizen.CreateThread(function(job)
	local location2 = Config.CoordSC
	local playerCoords = GetEntityCoords(GetPlayerPed(-1))
	local playerPed = GetPlayerPed(-1)
	local ped = GetPlayerPed(-1)

    local dict = Config.AnimLib
    local anim = Config.Anim
	while true do
	Citizen.Wait(500)
		if ESX.PlayerData.job.name == 'blackmarket' then
			if isNear7 then
				Draw3DText(location2.x, location2.y, location2.z, Config.Press .. Config.SpecialCarabine, 0.4)
			end
			if isNear7 then
				if IsControlJustReleased(0, 38) then
					RequestAnimDict(dict)
					while not HasAnimDictLoaded(dict) do
						Citizen.Wait(1)
					end
					ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(quantity)
						if quantity >= 250 then
							ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(quantity2)
								if quantity2 >= 250 then
									if not HasPedGotWeapon(ped, 0xC0A3098D, false) then
										SetEntityCoords(PlayerPedId(), Config.CoordSC.x, Config.CoordSC.y, Config.CoordSC.z, 0, 0, 0, 0)
										SetEntityHeading(PlayerPedId(), 183.0)
										TaskPlayAnim(ped, dict, anim, 12.0, 12.0, -1, 0, 0, 0, 40, 0)
										exports['progressBars']:startUI(5000, Config.ProgressBar)
										Citizen.Wait(5000)
										ClearPedTasks(ped)
										Citizen.Wait(100)
										TriggerServerEvent('craft:specialcarabine')
									else
										exports['mythic_notify']:DoHudText('server', Config.InventoryGun)
									end
								else
									exports['mythic_notify']:DoHudText('server', Config.NoIron)
								end
							end, 'iron')
						else
							exports['mythic_notify']:DoHudText('server', Config.NoPowder)
						end
					end, 'gunpowder')
				end
			end
		end
	end
end)

-- 2340.567, 3126.516, 48.20869

Citizen.CreateThread(function(job)
	local location2 = Config.CoordBarrett
	local playerPed = GetPlayerPed(-1)
	local playerCoords = GetEntityCoords(GetPlayerPed(-1))
	local ped = GetPlayerPed(-1)
    local dict = Config.AnimLib
    local anim = Config.Anim
	while true do
	Citizen.Wait(500)
		if ESX.PlayerData.job.name == 'blackmarket' then
			if isNear8 then
				Draw3DText(location2.x, location2.y, location2.z, Config.Press .. Config.Barrett, 0.4)
			end
			if isNear8 then
				if IsControlJustReleased(0, 38) then
					RequestAnimDict(dict)
					while not HasAnimDictLoaded(dict) do
						Citizen.Wait(1)
					end
					ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(quantity)
						if quantity >= 350 then
							ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(quantity2)
								if quantity2 >= 350 then
									if not HasPedGotWeapon(ped, 0x0C472FE2, false) then
										exports['mythic_notify']:DoHudText('server', Config.BarrettCrafting)
										SetEntityCoords(PlayerPedId(), Config.CoordBarrett.x, Config.CoordBarrett.y, Config.CoordBarrett.z, 0, 0, 0, 0)
										SetEntityHeading(PlayerPedId(), 14.0)
										TaskPlayAnim(ped, dict, anim, 12.0, 12.0, -1, 1, 0, 0, 40, 0)
										exports['progressBars']:startUI(50000, Config.ProgressBar)
										Citizen.Wait(50000)
										ClearPedTasks(ped)
										Citizen.Wait(100)
										TriggerServerEvent('craft:barrett')
									else
										exports['mythic_notify']:DoHudText('server', Config.InventoryGun)
									end
								else
									exports['mythic_notify']:DoHudText('server', Config.NoIron)
								end
							end, 'iron')
						else
							exports['mythic_notify']:DoHudText('server', Config.NoPowder)
						end
					end, 'gunpowder')
				end
			end
		end
	end
end)


Citizen.CreateThread(function(job)
	local location2 = Config.CoordIron
	local playerCoords = GetEntityCoords(GetPlayerPed(-1))
	local playerPed = GetPlayerPed(-1)
	local ped = GetPlayerPed(-1)

    local dict = "melee@large_wpn@streamed_core"
    local anim = "ground_attack_on_spot"
	while true do
	Citizen.Wait(500)
		if ESX.PlayerData.job.name == 'blackmarket' then
			if isNear9 then
				Draw3DText(location2.x, location2.y, location2.z, Config.IronMess, 0.4)
			end
			if isNear9 then
				if IsControlJustReleased(0, 38) then
					RequestAnimDict(dict)
					while not HasAnimDictLoaded(dict) do
						Citizen.Wait(1)
					end
					ClearPedTasks(ped)
					TaskPlayAnim(ped, dict, anim, 12.0, 12.0, -1, 1, 0, 0, 40, 0)
					pickaxe = CreateObject(GetHashKey("prop_tool_pickaxe"), 0, 0, 0, true, true, true) 
                    AttachEntityToEntity(pickaxe, PlayerPedId(), GetPedBoneIndex(PlayerPedId(), 57005), 0.05, -0.10, -0.03, -300.0, 90.00, 180.0, true, true, false, true, 1, true)
					SetCurrentPedWeapon(ped, GetHashKey("WEAPON_UNARMED"), true)
					exports['progressBars']:startUI(5000, Config.ProgressBarPU)
					Citizen.Wait(5000)
					TriggerServerEvent('pickup:iron')
					ClearPedTasks(ped)
                    DeleteEntity(pickaxe)
                    DeleteObject(pickaxe)
				end
			end
		end
	end
end)

Citizen.CreateThread(function(job)
	local location2 = Config.CoordGP
	local playerCoords = GetEntityCoords(GetPlayerPed(-1))
	local playerPed = GetPlayerPed(-1)
	local ped = GetPlayerPed(-1)

    local dict = "melee@large_wpn@streamed_core"
    local anim = "ground_attack_on_spot"
	while true do
	Citizen.Wait(500)
		if ESX.PlayerData.job.name == 'blackmarket' then
			if isNear10 then
				Draw3DText(location2.x, location2.y, location2.z, Config.GPMess, 0.4)
			end
			if isNear10 then
				if IsControlJustReleased(0, 38) then
					RequestAnimDict(dict)
					while not HasAnimDictLoaded(dict) do
						Citizen.Wait(1)
					end
					ClearPedTasks(ped)
					TaskPlayAnim(ped, dict, anim, 12.0, 12.0, -1, 1, 0, 0, 40, 0)
					pickaxe = CreateObject(GetHashKey("prop_tool_pickaxe"), 0, 0, 0, true, true, true) 
                    AttachEntityToEntity(pickaxe, PlayerPedId(), GetPedBoneIndex(PlayerPedId(), 57005), 0.05, -0.10, -0.03, -300.0, 90.00, 180.0, true, true, false, true, 1, true)
					SetCurrentPedWeapon(ped, GetHashKey("WEAPON_UNARMED"), true)
					exports['progressBars']:startUI(5000, Config.ProgressBarPU)
					Citizen.Wait(5000)
					TriggerServerEvent('pickup:GP')
					ClearPedTasks(ped)
                    DeleteEntity(pickaxe)
                    DeleteObject(pickaxe)
				end
			end
		end
	end
end)

--- Creazione BLIP

Citizen.CreateThread(function(job)
	while true do
	Citizen.Wait(500)
		if ESX.PlayerData.job.name == 'blackmarket' then
			local blip = AddBlipForCoord(Config.CoordBlip1)
			local blip2 = AddBlipForCoord(Config.CoordBlip2)
			local blip3 = AddBlipForCoord(Config.CoordBlip3)
			local blip4 = AddBlipForCoord(Config.CoordBlip4)
    		SetBlipSprite(blip, Config.Blip1Type)
     		SetBlipDisplay(blip, 2)
    		SetBlipScale(blip, Config.Blip1Scale)
    		SetBlipColour(blip, Config.BlipColour)
    		SetBlipAsShortRange(blip, true)
			BeginTextCommandSetBlipName("STRING")
     		AddTextComponentString(Config.BlipName)
			EndTextCommandSetBlipName(blip)
			-----
			SetBlipSprite(blip2, Config.Blip2Type)
			SetBlipDisplay(blip2, 2)
		    SetBlipScale(blip2, Config.Blip2Scale)
		    SetBlipColour(blip2, 1)
		    SetBlipAsShortRange(blip2, true)
		    BeginTextCommandSetBlipName("STRING")
			AddTextComponentString(Config.BlipName)
			EndTextCommandSetBlipName(blip2)
			---
			SetBlipSprite(blip3, Config.Blip3Type)
			SetBlipDisplay(blip3, 2)
		    SetBlipScale(blip3, Config.Blip3Scale)
		    SetBlipColour(blip3, 1)
		    SetBlipAsShortRange(blip3, true)
		    BeginTextCommandSetBlipName("STRING")
			AddTextComponentString(Config.BlipName3)
			EndTextCommandSetBlipName(blip3)
			---
			SetBlipSprite(blip4, Config.Blip4Type)
			SetBlipDisplay(blip4, 2)
		    SetBlipScale(blip4, Config.Blip4Scale)
		    SetBlipColour(527, 1)
		    SetBlipAsShortRange(blip4, true)
		    BeginTextCommandSetBlipName("STRING")
			AddTextComponentString(Config.BlipName2)
			EndTextCommandSetBlipName(blip4)
			break
		end
	end
end)

Citizen.CreateThread(function()
	local ped = PlayerPedId()
	local playerPed = GetPlayerPed(-1)
	local location = Config.CoordBarrett
	while true do
		local coords = GetEntityCoords(ped)
		Citizen.Wait(100)
		if Vdist(coords, Config.CoordBarrett.x, Config.CoordBarrett.y, Config.CoordBarrett.z) < 7 then
			isNear8 = true
		end
		if Vdist(coords, Config.CoordBarrett.x, Config.CoordBarrett.y, Config.CoordBarrett.z) > 1 then
			isNear8 = false
		end
		if Vdist(coords, Config.CoordBarrett.x, Config.CoordBarrett.y, Config.CoordBarrett.z) < 1 then
			isNear8 = true
		else
			isNear8 = false
		end
	end
end)

Citizen.CreateThread(function()
	local ped = PlayerPedId()
	local location = Config.CoordSC
	while true do
		local coords = GetEntityCoords(ped)
		Citizen.Wait(100)
		if Vdist(coords, Config.CoordSC.x, Config.CoordSC.y, Config.CoordSC.z) < 7 then
			isNear7 = true
		end
		if Vdist(coords, Config.CoordSC.x, Config.CoordSC.y, Config.CoordSC.z) > 1 then
			isNear7 = false
		end
		if Vdist(coords, Config.CoordSC.x, Config.CoordSC.y, Config.CoordSC.z) < 1 then
			isNear7 = true
		else
			isNear7 = false
		end
	end
end)

Citizen.CreateThread(function()
	local ped = PlayerPedId()
	local location = Config.CoordIron
	while true do
		local coords = GetEntityCoords(ped)
		Citizen.Wait(100)
		if Vdist(coords, Config.CoordIron.x, Config.CoordIron.y, Config.CoordIron.z) < 10 then
			isNear9 = true
		end
		if Vdist(coords, Config.CoordIron.x, Config.CoordIron.y, Config.CoordIron.z) > 10 then
			isNear9 = false
		end
	end
end)

Citizen.CreateThread(function()
	local ped = PlayerPedId()
	local location = Config.CoordGP
	while true do
		local coords = GetEntityCoords(ped)
		Citizen.Wait(100)
		if Vdist(coords, Config.CoordGP.x, Config.CoordGP.y, Config.CoordGP.z) < 5 then
			isNear10 = true
		end
		if Vdist(coords, Config.CoordGP.x, Config.CoordGP.y, Config.CoordGP.z) > 5 then
			isNear10 = false
		end
	end
end)



Citizen.CreateThread(function()
	local ped = PlayerPedId()
	local location = Config.CoordAk
	while true do
		local coords = GetEntityCoords(ped)
		Citizen.Wait(100)
		if Vdist(coords, Config.CoordAk.x, Config.CoordAk.y, Config.CoordAk.z) < 7 then
			isNear6 = true
		end
		if Vdist(coords, Config.CoordAk.x, Config.CoordAk.y, Config.CoordAk.z) > 1 then
			isNear6 = false
		end
		if Vdist(coords, Config.CoordAk.x, Config.CoordAk.y, Config.CoordAk.z) < 1 then
			isNear6 = true
		else
			isNear6 = false
		end
	end
end)

Citizen.CreateThread(function()
	local ped = PlayerPedId()
	local location = Config.CoordPistol50
	while true do
		local coords = GetEntityCoords(ped)
		Citizen.Wait(100)
		if Vdist(coords, Config.CoordShotGun.x, Config.CoordShotGun.y, Config.CoordShotGun.z) < 7 then
			isNear5 = true
		end
		if Vdist(coords, Config.CoordShotGun.x, Config.CoordShotGun.y, Config.CoordShotGun.z) > 1 then
			isNear5 = false
		end
		if Vdist(coords, Config.CoordShotGun.x, Config.CoordShotGun.y, Config.CoordShotGun.z) < 1 then
			isNear5 = true
		else
			isNear5 = false
		end
	end
end)

Citizen.CreateThread(function()
	local ped = PlayerPedId()
	local location = Config.CoordPistol50
	while true do
		local coords = GetEntityCoords(ped)
		Citizen.Wait(100)
		if Vdist(coords, Config.CoordPistol50.x, Config.CoordPistol50.y, Config.CoordPistol50.z) < 7 then
			isNear3 = true
		end
		if Vdist(coords, Config.CoordPistol50.x, Config.CoordPistol50.y, Config.CoordPistol50.z) > 1 then
			isNear3 = false
		end
		if Vdist(coords, Config.CoordPistol50.x, Config.CoordPistol50.y, Config.CoordPistol50.z) < 1 then
			isNear3 = true
		else
			isNear3 = false
		end
	end
end)

Citizen.CreateThread(function()
	local ped = PlayerPedId()
	local location = Config.CoordApPistol
	while true do
		local coords = GetEntityCoords(ped)
		Citizen.Wait(100)
		if Vdist(coords, Config.CoordApPistol.x, Config.CoordApPistol.y, Config.CoordApPistol.z) < 7 then
			isNear4 = true
		end
		if Vdist(coords, Config.CoordApPistol.x, Config.CoordApPistol.y, Config.CoordApPistol.z) > 1 then
			isNear4 = false
		end
		if Vdist(coords, Config.CoordApPistol.x, Config.CoordApPistol.y, Config.CoordApPistol.z) < 1 then
			isNear4 = true
		else
			isNear4 = false
		end
	end
end)

Citizen.CreateThread(function()
	local ped = PlayerPedId()
	local location = Config.CoordPistola
	while true do
		local coords = GetEntityCoords(ped)
		Citizen.Wait(100)
		if Vdist(coords, Config.CoordPistola.x, Config.CoordPistola.y, Config.CoordPistola.z) < 7 then
			isNear = true
		end
		if Vdist(coords, Config.CoordPistola.x, Config.CoordPistola.y, Config.CoordPistola.z) > 1 then
			isNear = false
		end
		if Vdist(coords, Config.CoordPistola.x, Config.CoordPistola.y, Config.CoordPistola.z) < 1 then
			isNear = true
		else
			isNear = false
		end
	end
end)

Citizen.CreateThread(function()
	local ped = PlayerPedId()
	local location2 = Config.CoordSMG
	while true do
		local coords = GetEntityCoords(ped)
		Citizen.Wait(100)
		if Vdist(coords, Config.CoordSMG.x, Config.CoordSMG.y, Config.CoordSMG.z) < 7 then
			isNear2 = true
		end
		if Vdist(coords, Config.CoordSMG.x, Config.CoordSMG.y, Config.CoordSMG.z) > 1 then
			isNear2 = false
		end
		if Vdist(coords, Config.CoordSMG.x, Config.CoordSMG.y, Config.CoordSMG.z) < 1 then
			isNear2 = true
		else
			isNear2 = false
		end
	end
end)




function Draw3DText(x, y, z, text, scale)
	local onScreen, _x, _y = World3dToScreen2d(x, y, z)
	local pX, pY, pZ = table.unpack(GetGameplayCamCoord())
	SetTextScale(scale, scale)
	SetTextFont(4)
	SetTextProportional(1)
	SetTextEntry("STRING")
	SetTextCentre(true)
	SetTextColour(255, 255, 255, 215)
	AddTextComponentString(text)
	DrawText(_x, _y)
	local factor = (string.len(text)) / 700
	DrawRect(_x, _y + 0.0150, 0.06 + factor, 0.03, 41, 11, 41, 100)
end


RegisterCommand('coord', function()
	local ciao = GetEntityCoords(PlayerPedId())
	local ciao2 = GetEntityHeading(PlayerPedId())
	print(ciao)
	print(ciao2)
end)

RegisterCommand('job', function()
	local job = ESX.PlayerData.job.label
	local jobgrade = ESX.PlayerData.job.grade_label
	print(job .. ": " .. jobgrade)
end)

Citizen.CreateThread(function()
	while true do
	Citizen.Wait(0)
	local job = ESX.PlayerData.job.label
	local jobgrade = ESX.PlayerData.job.grade_label
			SetTextFont(4)
			SetTextProportional(1)
			SetTextScale(0.0, 0.5)
			SetTextColour(255, 255, 255, 255)
			SetTextDropshadow(0, 0, 0, 0, 255)
			SetTextEdge(1, 0, 0, 0, 255)
			SetTextDropShadow()
			SetTextOutline()
			SetTextEntry("STRING")
			AddTextComponentString(job .. ": " .. jobgrade)
			DrawText(0.470, 0.005)
	end
end)

Jeez, that’s one wall of text lol. What exactly doesn’t work and requires the script to be restarted?

only the map blips appaer… the rest does not want load…

as u can see i tried to add Citizen.Wait(500) but i have to change it… it cause the 3d text flick

so any solution?

Hello,
try (before the boucle),

ESX.PlayerData = ESX.GetPlayerData()

i tried it… doesen’t work…

Achou alguma solução ? Estou enfrentando o mesmo problema, porém, em vRP.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.