QBCore = exports['qb-core']:GetCoreObject()

local marker = false
local sleep = 1000
local x = -529.02
local y = -201.53
local z = 37.65

CreateThread(function()
	while true do  
		local pedCoords = GetEntityCoords(PlayerPedId())
    local markerCoords = vector3(x, y, z)
    local dist = #(pedCoords - markerCoords)
    if dist < 40 and marker then
		  DrawMarker(21, x, y, z + 1, 0.0, 0.0, 0.0, 0.0, 180.0, 0.0, 1.3, 1.3, 1.3, 120, 10, 20, 50, false, true, 2, nil, nil, false)
      sleep = 0
    else 
      sleep = 1000
    end
		Wait(sleep)
	end
end)

function loc1()
  x = -529.02
  y = -201.53
  z = 37.65
  marker = true
  exports['qb-target']:AddBoxZone("loc1", vector3(-529.02, -201.53, 37.65), 0.6, 2.8, {
    name = "loc1",
    heading = 30,
    minZ = 33.65,
    maxZ = 37.65,
  }, {
    options = {
      {
        action = function(entity)
          if IsPedAPlayer(entity) then return false end
          TriggerEvent('nc-gardening:workbushes1')
        end,
        icon = 'fa fa-scissors',
        label = "Klip hæk",
        item = "shears"
      },
    },
    distance = 1.5
  })
end

function loc2()
  x = -527.45
  y = -202.06
  z = 37.65
  exports['qb-target']:AddBoxZone("loc2", vector3(-527.45, -202.06, 37.65), 0.6, 2.4, {
    name = "loc2",
    heading = 30,
    minZ = 33.45,
    maxZ = 37.45,
  }, {
    options = {
      {
        action = function(entity)
          if IsPedAPlayer(entity) then return false end
          TriggerEvent('nc-gardening:workbushes2')
        end,
        icon = 'fa fa-scissors',
        label = "Klip hæk",
        item = "shears"
      },
    },
    distance = 1.5
  })
end

function loc3()
  x = -528.22
  y = -205.03
  z = 38.18
  exports['qb-target']:AddBoxZone("loc3", vector3(-528.22, -205.03, 38.18), 4.0, 1, {
    name = "loc3",
    heading = 255,
    minZ = 33.58,
    maxZ = 37.58,
  }, {
    options = {
      {
        action = function(entity)
          if IsPedAPlayer(entity) then return false end
          TriggerEvent('nc-gardening:workbushes3')
        end,
        icon = 'fa fa-scissors',
        label = "Klip hæk",
        item = "shears"
      },
    },
    distance = 1.5
  })
end

function loc4()
  x = -522.46
  y = -210.7
  z = 37.65
  exports['qb-target']:AddBoxZone("loc4", vector3(-522.46, -210.7, 37.65), 0.6, 3.0, {
    name = "loc4",
    heading = 120,
    minZ = 33.45,
    maxZ = 37.45,
  }, {
    options = {
      {
        action = function(entity)
          if IsPedAPlayer(entity) then return false end
          TriggerEvent('nc-gardening:workbushes4')
        end,
        icon = 'fa fa-scissors',
        label = "Klip hæk",
        item = "shears"
      },
    },
    distance = 1.5
  })
end

function loc5()
  x = -523.07
  y = -212.23
  z = 37.7
  exports['qb-target']:AddBoxZone("loc5", vector3(-523.07, -212.23, 37.7), 0.6, 2.6, {
    name = "loc5",
    heading = 30,
    minZ = 33.5,
    maxZ = 37.5,
  }, {
    options = {
      {
        action = function(entity)
          if IsPedAPlayer(entity) then return false end
          TriggerEvent('nc-gardening:workbushes5')
        end,
        icon = 'fa fa-scissors',
        label = "Klip hæk",
        item = "shears"
      },
    },
    distance = 1.5
  })
end

function loc6()
  x = -525.27
  y = -210.11
  z = 37.7
  exports['qb-target']:AddBoxZone("loc6", vector3(-525.27, -210.11, 37.7), 4.2, 0.8, {
    name = "loc6",
    heading = 350,
    minZ = 33.7,
    maxZ = 37.7,
  }, {
    options = {
      {
        action = function(entity)
          if IsPedAPlayer(entity) then return false end
          TriggerEvent('nc-gardening:workbushes6')
        end,
        icon = 'fa fa-scissors',
        label = "Klip hæk",
        item = "shears"
      },
    },
    distance = 1.5
  })
end

function loc7()
  x = -530.36
  y = -213.53
  z = 37.68
  exports['qb-target']:AddBoxZone("loc7", vector3(-530.36, -213.53, 37.68), 3.2, 0.8, {
    name = "loc7",
    heading = 80,
    minZ = 33.48,
    maxZ = 37.48,
  }, {
    options = {
      {
        action = function(entity)
          if IsPedAPlayer(entity) then return false end
          TriggerEvent('nc-gardening:workbushes7')
        end,
        icon = 'fa fa-scissors',
        label = "Klip hæk",
        item = "shears"
      },
    },
    distance = 1.5
  })
end

function loc8()
  x = -530.2
  y = -216.53
  z = 37.6
  exports['qb-target']:AddBoxZone("loc8", vector3(-530.2, -216.53, 37.6), 0.6, 2.2, {
    name = "loc8",
    heading = 30,
    minZ = 33.6,
    maxZ = 37.6,
  }, {
    options = {
      {
        action = function(entity)
          if IsPedAPlayer(entity) then return false end
          TriggerEvent('nc-gardening:workbushes8')
        end,
        icon = 'fa fa-scissors',
        label = "Klip hæk",
        item = "shears"
      },
    },
    distance = 1.5
  })
end

function loc9()
  x = -531.9
  y = -215.97
  z = 37.65
  exports['qb-target']:AddBoxZone("loc9", vector3(-531.9, -215.97, 37.65), 2.4, 0.6, {
    name = "loc9",
    heading = 30,
    minZ = 33.65,
    maxZ = 37.65,
  }, {
    options = {
      {
        action = function(entity)
          if IsPedAPlayer(entity) then return false end
          TriggerEvent('nc-gardening:workbushes9')
          marker = false
        end,
        icon = 'fa fa-scissors',
        label = "Klip hæk",
        item = "shears"
      },
    },
    distance = 1.5
  })
end