Cant enable action that have been disabled

i was able to disable some action and the wheel menu but i cant seemto reactivate it when its been disabled.

	if data.current.value == 'citizen_wear' then
			onDuty = false
			
	
			Citizen.CreateThread(function()
    while true do
        Citizen.Wait(5)
       
EnableControlAction(1, 140, true)
EnableControlAction(1, 141, true)
EnableControlAction(1, 142, true)
EnableControlAction(0, 21, true)
EnableControlAction(1, 37, true)
    end
  end)

	elseif data.current.value == 'job_wear' then
			onDuty = true
 

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(5)
       
DisablePlayerFiring(PlayerPedId(), true) 
DisableControlAction(1, 140, true)
DisableControlAction(1, 141, true)
DisableControlAction(1, 142, true)
DisableControlAction(0, 21, true)
DisableControlAction(1, 37, true)

    
          
    
    end
    
end)

Have tried to use ?

EnableControlAction(0, 21, false)

instead of

DisableControlAction(1, 21, true)

here what i tried… didnt worked…

	if data.current.value == 'citizen_wear' then
			onDuty = false
			
	
			Citizen.CreateThread(function()
    while true do
        Citizen.Wait(5)
       
EnableControlAction(0, 140, false)
EnableControlAction(0, 141, false)
EnableControlAction(0, 142, false)
EnableControlAction(0, 21, false)
EnableControlAction(0, 37, false)
    end
  end)
	
			
	
Citizen.CreateThread(function()
while true do
Citizen.Wait(5)
  if data.current.value == 'citizen_wear' then
    onDuty = false
    EnableControlAction(1, 140, true)
    EnableControlAction(1, 141, true)
    EnableControlAction(1, 142, true)
    EnableControlAction(0, 21, true)
    EnableControlAction(1, 37, true)


  elseif data.current.value == 'job_wear' then

  onDuty = true
  DisablePlayerFiring(PlayerPedId(), true) 
  DisableControlAction(1, 140, true)
  DisableControlAction(1, 141, true)
  DisableControlAction(1, 142, true)
  DisableControlAction(0, 21, true)
  DisableControlAction(1, 37, true)

    
 end 
end)

DOESNT WORK strill not able to regan acces to the wheel menu or attacking… its blocked forever…

Is it your full script?

here is my full script

local Keys = {
  ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
  ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
  ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
  ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
  ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
  ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
  ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
  ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
  ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
}

local PlayerData = {}
local menuIsShowed = false
local hintIsShowed = false
local hasAlreadyEnteredMarker = false
local Blips = {}
local JobBlips = {}
local isInMarker = false
local isInPublicMarker = false

local hintToDisplay = "no hint to display"
local onDuty = false
local spawner = 0
local myPlate = {}

local vehicleObjInCaseofDrop = nil
local vehicleInCaseofDrop = nil

local vehicleMaxHealth = nil

local mission1on = 0
local countkill = 0
--local ped = PlayerPedId()

local countnumberofdead = 0

ESX = nil



local MeeleWeapons = {
    ["WEAPON_NIGHTSTICK"] = 0.1,
    ["WEAPON_BAT"] = 0.000001
}





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(10)
	end

	PlayerData = ESX.GetPlayerData()
	refreshBlips()
end)



RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)
	PlayerData = xPlayer
	refreshBlips()
end)

	

function OpenMenu()



	ESX.UI.Menu.CloseAll()

	ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'cloakroom',
	{
		title    = _U('cloakroom'),
		elements = {
			{label = _U('Start mission'),     value = 'job_wear'},



			{label = _U('Stop mission'), value = 'citizen_wear'}


		}






	}, function(data, menu)
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin)
				TriggerEvent('skinchanger:loadSkin', skin)
			end)




		if data.current.value == 'citizen_wear' then
			onDuty = false
			
	       
EnableControlAction(1, 140, true)
EnableControlAction(1, 141, true)
EnableControlAction(1, 142, true)
EnableControlAction(0, 21, true)
EnableControlAction(1, 37, true)
  


--EnablePlayerFiring(PlayerPedId(), true) 

----------------------------------------------------------------------------------------------
if mission1on == 1 then




countnumberofdead = 1
peddead()




TriggerEvent("mt:missiontext", "Mission terminee!", 2000)
Wait(2000)
TriggerEvent("mt:missiontext", "Nombre  d'ennemis tues:", 2000)
Wait(2000)
TriggerEvent("mt:missiontext", countkill, 2000)
Wait(2000)
TriggerEvent("mt:missiontext", "Paie total:" , 2000)
Wait(2000)
TriggerEvent("mt:missiontext", countkill * 10, 2000)
TriggerServerEvent('esx_jobs:paymission')
countkill = 0
mission1on = 0








end
----------------------------------------------------------------------------------------------
		

	ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin)
				TriggerEvent('skinchanger:loadSkin', skin)
			end)
		elseif data.current.value == 'job_wear' then
			onDuty = true
 

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(5)
       
DisablePlayerFiring(PlayerPedId(), true) 
DisableControlAction(1, 140, true)
DisableControlAction(1, 141, true)
DisableControlAction(1, 142, true)
DisableControlAction(0, 21, true)
DisableControlAction(1, 37, true)

    
          
    
    end
    
end)


	ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
				if skin.sex == 0 then
					TriggerEvent('skinchanger:loadClothes', skin, jobSkin.skin_male)



if mission1on == 0 then


TriggerEvent("mt:missiontext", "Bat toi contre des bandits.", 5000)
Wait(5000)
TriggerEvent("mt:missiontext", "Si tu n'est pas assez fort va t'entrainer.", 3000)

--TriggerEvent("mt:missiontext", mypay, 2000)

local trackedPeds = {}

function deleteEntity(entity)
	Citizen.InvokeNative(0xAE3CBE5BF394C9C9, Citizen.PointerValueIntInitialized(entity))
end


function peddead()
if countnumberofdead == 1 then

	
for a = 1, #trackedPeds do
if IsEntityDead(trackedPeds[a]) then
DeleteEntity(trackedPeds[a])
countkill = countkill +1
TriggerServerEvent('esx_jobs:paymission1')

else
DeleteEntity(trackedPeds[a])



			--PlaySound(-1, "LOCAL_PLYR_CASH_COUNTER_INCREASE", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS", 0, 0, 1)
		end
end
end


trackedPeds = 0

end




Citizen.CreateThread(function()
	while true do
		Wait(1)
		
	end
end)


-- delete entity when aimed at and killed
--TriggerServerEvent('esx_jobs:paymission1')
--countkill = countkill + 1





mission1on = 1
















	AddRelationshipGroup("bandits1")



local hash = GetHashKey( "a_m_y_mexthug_01" )
  while not HasModelLoaded( hash ) do
    RequestModel( hash )
    Wait(20)
end


    

  local pos =  GetEntityCoords(GetPlayerPed(-1))
  local ped =  CreatePed(4, hash, -316.296, -967.748, 31.0806, 0.0, true, true)
table.insert(trackedPeds, ped)
SetPedRelationshipGroupHash(ped, GetHashKey("bandits1"))
SetPedFleeAttributes(ped, 0, 0)
SetPedCombatAttributes(ped, 46, 1) 
SetPedCombatMovement(ped, 2)
SetPedArmour(ped, 9)
SetPedSuffersCriticalHits(ped, false)


  local pos =  GetEntityCoords(GetPlayerPed(-1))
  local ped =  CreatePed(4, hash, -318.296, -967.748, 31.0806, 0.0, true, true)
table.insert(trackedPeds, ped)
SetPedRelationshipGroupHash(ped, GetHashKey("bandits1"))
SetPedFleeAttributes(ped, 0, 0)
SetPedCombatAttributes(ped, 46, 1) 
SetPedCombatMovement(ped, 2)

 local pos =  GetEntityCoords(GetPlayerPed(-1))
  local ped =  CreatePed(4, hash, -320.296, -967.748, 31.0806, 0.0, true, true)
table.insert(trackedPeds, ped)
SetPedRelationshipGroupHash(ped, GetHashKey("bandits1"))
SetPedFleeAttributes(ped, 0, 0)
SetPedCombatAttributes(ped, 46, 1) 
SetPedCombatMovement(ped, 2)
SetPedSuffersCriticalHits(ped, true)



  local pos =  GetEntityCoords(GetPlayerPed(-1))
  local ped =  CreatePed(4, hash, -322.296, -967.748, 31.0806, 0.0, true, true)
table.insert(trackedPeds, ped)
SetPedRelationshipGroupHash(ped, GetHashKey("bandits1"))
SetPedFleeAttributes(ped, 0, 0)
SetPedCombatAttributes(ped, 46, 1) 
SetPedCombatMovement(ped, 2)
SetPedSuffersCriticalHits(ped, false)


  local pos =  GetEntityCoords(GetPlayerPed(-1))
  local ped =  CreatePed(4, hash, -324.631, -958.67, 31.0806, 0.0, true, true)
table.insert(trackedPeds, ped)
SetPedRelationshipGroupHash(ped, GetHashKey("bandits1"))
SetPedFleeAttributes(ped, 0, 0)
SetPedCombatAttributes(ped, 46, 1) 
SetPedCombatMovement(ped, 2)


  local pos =  GetEntityCoords(GetPlayerPed(-1))
  local ped =  CreatePed(4, hash, -329.251, -956.755, 31.0806, 0.0, true, true)
table.insert(trackedPeds, ped)
SetPedRelationshipGroupHash(ped, GetHashKey("bandits1"))
SetPedFleeAttributes(ped, 0, 0)
SetPedCombatAttributes(ped, 46, 1) 
SetPedCombatMovement(ped, 2)


  local pos =  GetEntityCoords(GetPlayerPed(-1))
  local ped =  CreatePed(4, hash, -339.94, -960.781, 31.0806, 0.0, true, true)
table.insert(trackedPeds, ped)
SetPedRelationshipGroupHash(ped, GetHashKey("bandits1"))
SetPedFleeAttributes(ped, 0, 0)
SetPedCombatAttributes(ped, 46, 1) 
SetPedCombatMovement(ped, 2)


  local pos =  GetEntityCoords(GetPlayerPed(-1))
  local ped =  CreatePed(4, hash, -340.257, -960.781, 31.0806, 0.0, true, true)
table.insert(trackedPeds, ped)
SetPedRelationshipGroupHash(ped, GetHashKey("bandits1"))
SetPedFleeAttributes(ped, 0, 0)
SetPedCombatAttributes(ped, 46, 1) 
SetPedCombatMovement(ped, 2)



  local pos =  GetEntityCoords(GetPlayerPed(-1))
  local ped =  CreatePed(4, hash, -341.257, -960.781, 31.0806, 0.0, true, true)
table.insert(trackedPeds, ped)
SetPedRelationshipGroupHash(ped, GetHashKey("bandits1"))
SetPedFleeAttributes(ped, 0, 0)
SetPedCombatAttributes(ped, 46, 1) 
SetPedCombatMovement(ped, 2)



  local pos =  GetEntityCoords(GetPlayerPed(-1))
  local ped =  CreatePed(4, hash, -342.257, -960.781, 31.0806, 0.0, true, true)
table.insert(trackedPeds, ped)
SetPedRelationshipGroupHash(ped, GetHashKey("bandits1"))
SetPedFleeAttributes(ped, 0, 0)
SetPedCombatAttributes(ped, 46, 1) 
SetPedCombatMovement(ped, 2)


  local pos =  GetEntityCoords(GetPlayerPed(-1))
  local ped =  CreatePed(4, hash, -343.257, -960.781, 31.0806, 0.0, true, true)
table.insert(trackedPeds, ped)
SetPedRelationshipGroupHash(ped, GetHashKey("bandits1"))
SetPedFleeAttributes(ped, 0, 0)
SetPedCombatAttributes(ped, 46, 1) 
SetPedCombatMovement(ped, 2)


  local pos =  GetEntityCoords(GetPlayerPed(-1))
  local ped =  CreatePed(4, hash, -344.257, -960.781, 31.0806, 0.0, true, true)
table.insert(trackedPeds, ped)
SetPedRelationshipGroupHash(ped, GetHashKey("bandits1"))
SetPedFleeAttributes(ped, 0, 0)
SetPedCombatAttributes(ped, 46, 1) 
SetPedCombatMovement(ped, 2)


  local pos =  GetEntityCoords(GetPlayerPed(-1))
  local ped =  CreatePed(4, hash, -345.257, -960.781, 31.0806, 0.0, true, true)
table.insert(trackedPeds, ped)
SetPedRelationshipGroupHash(ped, GetHashKey("bandits1"))
SetPedFleeAttributes(ped, 0, 0)
SetPedCombatAttributes(ped, 46, 1) 
SetPedCombatMovement(ped, 2)



  local pos =  GetEntityCoords(GetPlayerPed(-1))
  local ped =  CreatePed(4, hash, -351, -950, 31.0806, 0.0, true, true)
table.insert(trackedPeds, ped)
SetPedRelationshipGroupHash(ped, GetHashKey("bandits1"))
SetPedFleeAttributes(ped, 0, 0)
SetPedCombatAttributes(ped, 46, 1) 
SetPedCombatMovement(ped, 2)




  local pos =  GetEntityCoords(GetPlayerPed(-1))
  local ped =  CreatePed(4, hash, -352, -950, 31.0806, 0.0, true, true)
table.insert(trackedPeds, ped)
SetPedRelationshipGroupHash(ped, GetHashKey("bandits1"))
SetPedFleeAttributes(ped, 0, 0)
SetPedCombatAttributes(ped, 46, 1) 
SetPedCombatMovement(ped, 2)



  local pos =  GetEntityCoords(GetPlayerPed(-1))
  local ped =  CreatePed(4, hash, -353, -950, 31.0806, 0.0, true, true)
SetPedRelationshipGroupHash(ped, GetHashKey("bandits1"))
SetPedFleeAttributes(ped, 0, 0)
SetPedCombatAttributes(ped, 46, 1) 
SetPedCombatMovement(ped, 2)



  local pos =  GetEntityCoords(GetPlayerPed(-1))
  local ped =  CreatePed(4, hash, -354, -950, 31.0806, 0.0, true, true)
SetPedRelationshipGroupHash(ped, GetHashKey("bandits1"))
SetPedFleeAttributes(ped, 0, 0)
SetPedCombatAttributes(ped, 46, 1) 
SetPedCombatMovement(ped, 2)




  local pos =  GetEntityCoords(GetPlayerPed(-1))
  local ped =  CreatePed(4, hash, -355, -950, 31.0806, 0.0, true, true)
table.insert(trackedPeds, ped)
SetPedRelationshipGroupHash(ped, GetHashKey("bandits1"))
SetPedFleeAttributes(ped, 0, 0)
SetPedCombatAttributes(ped, 46, 1) 
SetPedCombatMovement(ped, 2)




  local pos =  GetEntityCoords(GetPlayerPed(-1))
  local ped =  CreatePed(4, hash, -356, -950, 31.0806, 0.0, true, true)
table.insert(trackedPeds, ped)
SetPedRelationshipGroupHash(ped, GetHashKey("bandits1"))
SetPedFleeAttributes(ped, 0, 0)
SetPedCombatAttributes(ped, 46, 1) 
SetPedCombatMovement(ped, 2)





	SetRelationshipBetweenGroups(5, GetHashKey("bandits1"), GetHashKey("PLAYER"))

	SetRelationshipBetweenGroups(5, GetHashKey("PLAYER"), GetHashKey("bandits1"))



 


end
----------------------------------------------------------------------------------------------







				else
					TriggerEvent('skinchanger:loadClothes', skin, jobSkin.skin_female)
				end
			end)
		end

		menu.close()
	end, function(data, menu)
		menu.close()
	end)
end







AddEventHandler('esx_jobs:action', function(job, zone)
	menuIsShowed = true
	if zone.Type == "cloakroom" then
		OpenMenu()
	elseif zone.Type == "work" then
		hintToDisplay = "no hint to display"
		hintIsShowed = false
		local playerPed = PlayerPedId()

		if IsPedInAnyVehicle(playerPed, false) then
			ESX.ShowNotification(_U('foot_work'))
		else
			TriggerServerEvent('esx_jobs:startWork', zone.Item)
		end
	elseif zone.Type == "vehspawner" then
		local spawnPoint = nil
		local vehicle = nil

		for k,v in pairs(Config.Jobs) do
			if PlayerData.job.name == k then
				for l,w in pairs(v.Zones) do
					if w.Type == "vehspawnpt" and w.Spawner == zone.Spawner then
						spawnPoint = w
						spawner = w.Spawner
					end
				end

				for m,x in pairs(v.Vehicles) do
					if x.Spawner == zone.Spawner then
						vehicle = x
					end
				end
			end
		end

		if ESX.Game.IsSpawnPointClear(spawnPoint.Pos, 5.0) then
			spawnVehicle(spawnPoint, vehicle, zone.Caution)
		else
			ESX.ShowNotification(_U('spawn_blocked'))
		end

	elseif zone.Type == "vehdelete" then
		local looping = true

		for k,v in pairs(Config.Jobs) do
			if PlayerData.job.name == k then
				for l,w in pairs(v.Zones) do
					if w.Type == "vehdelete" and w.Spawner == zone.Spawner then
						local playerPed = PlayerPedId()

						if IsPedInAnyVehicle(playerPed, false) then

							local vehicle = GetVehiclePedIsIn(playerPed, false)
							local plate = GetVehicleNumberPlateText(vehicle)
							plate = string.gsub(plate, " ", "")
							local driverPed = GetPedInVehicleSeat(vehicle, -1)

							if playerPed == driverPed then

								for i=1, #myPlate, 1 do
									if myPlate[i] == plate then

										local vehicleHealth = GetVehicleEngineHealth(vehicleInCaseofDrop)
										local giveBack = ESX.Math.Round(vehicleHealth / vehicleMaxHealth, 2)

										TriggerServerEvent('esx_jobs:caution', "give_back", giveBack, 0, 0)
										DeleteVehicle(GetVehiclePedIsIn(playerPed, false))

										if w.Teleport ~= 0 then
											ESX.Game.Teleport(playerPed, w.Teleport)
										end

										table.remove(myPlate, i)

										if vehicleObjInCaseofDrop.HasCaution then
											vehicleInCaseofDrop = nil
											vehicleObjInCaseofDrop = nil
											vehicleMaxHealth = nil
										end

										break
									end
								end

							else
								ESX.ShowNotification(_U('not_your_vehicle'))
							end

						end

						looping = false
						break
					end

					if looping == false then
						break
					end
				end
			end
			if looping == false then
				break
			end
		end
	elseif zone.Type == "delivery" then
		if Blips['delivery'] ~= nil then
			RemoveBlip(Blips['delivery'])
			Blips['delivery'] = nil
		end

		hintToDisplay = "no hint to display"
		hintIsShowed = false
		TriggerServerEvent('esx_jobs:startWork', zone.Item)
	end
	--nextStep(zone.GPS)
end)

function nextStep(gps)
	if gps ~= 0 then
		if Blips['delivery'] ~= nil then
			RemoveBlip(Blips['delivery'])
			Blips['delivery'] = nil
		end

		Blips['delivery'] = AddBlipForCoord(gps.x, gps.y, gps.z)
		SetBlipRoute(Blips['delivery'], true)
		ESX.ShowNotification(_U('next_point'))
	end
end

AddEventHandler('esx_jobs:hasExitedMarker', function(zone)
	TriggerServerEvent('esx_jobs:stopWork')
	hintToDisplay = "no hint to display"
	menuIsShowed = false
	hintIsShowed = false
	isInMarker = false



end)



RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
	PlayerData.job = job
	onDuty = false
	myPlate = {} -- loosing vehicle caution in case player changes job.
	spawner = 0
	deleteBlips()
	refreshBlips()
end)

function deleteBlips()
	if JobBlips[1] ~= nil then
		for i=1, #JobBlips, 1 do
			RemoveBlip(JobBlips[i])
			JobBlips[i] = nil
		end
	end
end

function refreshBlips()
	local zones = {}
	local blipInfo = {}

	if PlayerData.job ~= nil then
		for jobKey,jobValues in pairs(Config.Jobs) do

			if jobKey == PlayerData.job.name then
				for zoneKey,zoneValues in pairs(jobValues.Zones) do

					if zoneValues.Blip then
						local blip = AddBlipForCoord(zoneValues.Pos.x, zoneValues.Pos.y, zoneValues.Pos.z)
						SetBlipSprite  (blip, jobValues.BlipInfos.Sprite)
						SetBlipDisplay (blip, 4)
						SetBlipScale   (blip, 1.2)
						SetBlipCategory(blip, 3)
						SetBlipColour  (blip, jobValues.BlipInfos.Color)
						SetBlipAsShortRange(blip, true)

						BeginTextCommandSetBlipName("STRING")
						AddTextComponentString(zoneValues.Name)
						EndTextCommandSetBlipName(blip)
						table.insert(JobBlips, blip)
					end
				end
			end
		end
	end
end



function spawnVehicle(spawnPoint, vehicle, vehicleCaution)
	hintToDisplay = 'no hint to display'
	hintIsShowed = false
	TriggerServerEvent('esx_jobs:caution', 'take', vehicleCaution, spawnPoint, vehicle)
end

RegisterNetEvent('esx_jobs:spawnJobVehicle')
AddEventHandler('esx_jobs:spawnJobVehicle', function(spawnPoint, vehicle)
	local playerPed = PlayerPedId()

	ESX.Game.SpawnVehicle(vehicle.Hash, spawnPoint.Pos, spawnPoint.Heading, function(spawnedVehicle)

		if vehicle.Trailer ~= "none" then
			ESX.Game.SpawnVehicle(vehicle.Trailer, spawnPoint.Pos, spawnPoint.Heading, function(trailer)
				AttachVehicleToTrailer(spawnedVehicle, trailer, 1.1)
			end)
		end

		-- save & set plate
		local plate = 'WORK' .. math.random(100, 900)
		SetVehicleNumberPlateText(spawnedVehicle, plate)
		table.insert(myPlate, plate)
		plate = string.gsub(plate, " ", "")

		TaskWarpPedIntoVehicle(playerPed, spawnedVehicle, -1)

		if vehicle.HasCaution then
			vehicleInCaseofDrop = spawnedVehicle
			vehicleObjInCaseofDrop = vehicle
			vehicleMaxHealth = GetVehicleEngineHealth(spawnedVehicle)
		end
	end)
end)

-- Show top left hint
Citizen.CreateThread(function()
	while true do
		Citizen.Wait(10)

		if hintIsShowed then
			ESX.ShowHelpNotification(hintToDisplay)
		else
			Citizen.Wait(500)
		end
	end
end)

-- Display markers (only if on duty and the player's job ones)
Citizen.CreateThread(function()
	while true do
		Citizen.Wait(1)
		local zones = {}

		if PlayerData.job ~= nil then
			for k,v in pairs(Config.Jobs) do
				if PlayerData.job.name == k then
					zones = v.Zones
				end
			end

			local coords = GetEntityCoords(PlayerPedId())
			for k,v in pairs(zones) do
				if onDuty or v.Type == "cloakroom" or PlayerData.job.name == "reporter" then
					if(v.Marker ~= -1 and GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.DrawDistance) then
						DrawMarker(v.Marker, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, v.Size.x, v.Size.y, v.Size.z, v.Color.r, v.Color.g, v.Color.b, 100, false, true, 2, false, false, false, false)
					end
				end
			end
		end
	end
end)

-- Display public markers
Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		local coords = GetEntityCoords(PlayerPedId())
		for k,v in pairs(Config.PublicZones) do
			if(v.Marker ~= -1 and GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < Config.DrawDistance) then
				DrawMarker(v.Marker, v.Pos.x, v.Pos.y, v.Pos.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, v.Size.x, v.Size.y, v.Size.z, v.Color.r, v.Color.g, v.Color.b, 100, false, true, 2, false, false, false, false)
			end
		end
	end
end)

-- Activate public marker
Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		local coords   = GetEntityCoords(PlayerPedId())
		local position = nil
		local zone     = nil

		for k,v in pairs(Config.PublicZones) do
			if GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < v.Size.x/2 then
				isInPublicMarker = true
				position = v.Teleport
				zone = v
				break
			else
				isInPublicMarker = false
			end
		end

		if IsControlJustReleased(0, Keys['E']) and isInPublicMarker then
			ESX.Game.Teleport(PlayerPedId(), position)
			isInPublicMarker = false
		end

		-- hide or show top left zone hints
		if isInPublicMarker then
			hintToDisplay = zone.Hint
			hintIsShowed = true
		else
			if not isInMarker then
				hintToDisplay = "no hint to display"
				hintIsShowed = false
			end
		end
	end
end)

-- Activate menu when player is inside marker
Citizen.CreateThread(function()
	while true do

		Citizen.Wait(1)

		if PlayerData.job ~= nil and PlayerData.job.name ~= 'unemployed' then
			local zones = nil
			local job = nil

			for k,v in pairs(Config.Jobs) do
				if PlayerData.job.name == k then
					job = v
					zones = v.Zones
				end
			end

			if zones ~= nil then
				local coords      = GetEntityCoords(PlayerPedId())
				local currentZone = nil
				local zone        = nil
				local lastZone    = nil

				for k,v in pairs(zones) do
					if GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < v.Size.x then
						isInMarker  = true
						currentZone = k
						zone        = v
						break
					else
						isInMarker  = false
					end
				end

				if IsControlJustReleased(0, Keys['E']) and not menuIsShowed and isInMarker then
					if onDuty or zone.Type == "cloakroom" or PlayerData.job.name == "reporter" then
						TriggerEvent('esx_jobs:action', job, zone)
					end
				end

				-- hide or show top left zone hints
				if isInMarker and not menuIsShowed then
					hintIsShowed = true
					if (onDuty or zone.Type == "cloakroom" or PlayerData.job.name == "reporter") and zone.Type ~= "vehdelete" then
						hintToDisplay = zone.Hint
						hintIsShowed = true
					elseif zone.Type == "vehdelete" and (onDuty or PlayerData.job.name == "reporter") then
						local playerPed = PlayerPedId()

						if IsPedInAnyVehicle(playerPed, false) then
							local vehicle = GetVehiclePedIsIn(playerPed, false)
							local driverPed = GetPedInVehicleSeat(vehicle, -1)
							local plate = GetVehicleNumberPlateText(vehicle)
							plate = string.gsub(plate, " ", "")

							if playerPed == driverPed then

								for i=1, #myPlate, 1 do
									if myPlate[i] == plate then
										hintToDisplay = zone.Hint
										break
									end
								end

							else
								hintToDisplay = _U('not_your_vehicle')
							end
						else
							hintToDisplay = _U('in_vehicle')
						end
						hintIsShowed = true
					elseif onDuty and zone.Spawner ~= spawner then
						hintToDisplay = _U('wrong_point')
						hintIsShowed = true
					else
						if not isInPublicMarker then
							hintToDisplay = "no hint to display"
							hintIsShowed = false
						end
					end
				end

				if isInMarker and not hasAlreadyEnteredMarker then
					hasAlreadyEnteredMarker = true
				end

				if not isInMarker and hasAlreadyEnteredMarker then
					hasAlreadyEnteredMarker = false
					TriggerEvent('esx_jobs:hasExitedMarker', zone)
				end
			end
		end
	end
end)



Citizen.CreateThread(function()
	-- Slaughterer
	RemoveIpl("CS1_02_cf_offmission")
	RequestIpl("CS1_02_cf_onmission1")
	RequestIpl("CS1_02_cf_onmission2")
	RequestIpl("CS1_02_cf_onmission3")
	RequestIpl("CS1_02_cf_onmission4")

	-- Tailor
	RequestIpl("id2_14_during_door")
	RequestIpl("id2_14_during1")
end)

Hi i’ve finally find what is causing your issue because i’ve used this natives recently.
You should call this natives each frame so you just need to use:

Citizen.Wait(0)

instead of

Citizen.Wait(5)

Hi,
to clarify at Disable most inputs when dead, you need to change Citizen.Wait(0) to Citizen.Wait(5)?

I am unable to get my ENTER/NENTER key to work but F1, arrow keys etc works fine!

Hi the fact is that you need to call it each frame. So yes, wait(0) .

Not exactly sure why but I got all keys to work EXCEPT ‘ENTER’ and ‘NENTER’ key. I just want them to be able to make a call to their friends if they are down/dead. Any ideas?

Attached code below:
isdead

1 Like