ESX Advanced Duty

Thanks :slight_smile: If you mean the french naming yeah itā€™s just iā€™ve not gone through yet and changed them to English.

I will do later tonight when Iā€™m on my pc, do you think itā€™s because Iā€™m possibly missing the offpolice on the jobs table?

Also, if this solves the SQL error will the duty circle appear? I canā€™t seem to see it anywhere in Mission Rowā€¦?

If you donā€™t see the circle, just change the coords, we might not having the same interior.

I dont see recruit where offpolice is, (0 grade), also, label doesnt do anything even if thats different, it takes only the grade and the job.

The other thing is that you probably havenā€™t added offpolice where jobs table is.

Good point, where is the default police interior youā€™ve made set to?

Also what police station are you using?

Yeah you should have them in the jobs table as well

In the same place, i am just using Gabz Police Department (paid interior).

1 Like

Yeah Iā€™m gonna pick that up later, where abouts is the default place though? in the reception?

It is yes but in Gabz, why not changing coords than trying to find where is located? You can edit from config or even teleport to the coords.

How would I make it so that when you go off duty all your weapons get taken away from you. (When clocking off duty.).

That must be done by your developer unfortunately, also, i donā€™t find it a great idea because they might be carrying weapons they purchased.

When I go on duty, it doesnā€™t detect that iā€™ve entered service. The jobs for sure change ā€“ but then I try to use the Police Armory and it says I need to change clothes as Iā€™ve not entered service. Any ideas?

That might be a problem of the job script, i had this in many scripts and i had to manually edit them, try doing it in other jobs to confirm if thats the issue.

I feel like sharing this code as I couldnā€™t find it anywhere and wish to help anyone who also needs it. It makes it so you can toggle duty from your F6 menu instead of always having to go back to the station.

STEPS:

  1. Make sure you have installed this resource (esx_advanced_duty).
  2. For this example Iā€™ll be doing this for the esx_policejob. Locate the esx_policejob folder and find esx_policejob > client > main.lua.
  3. Look for this code:
	ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'police_actions', {
		title    = 'Police',
		align    = 'right',
		elements = {
			{label = _U('citizen_interaction'), value = 'citizen_interaction'},
			{label = _U('vehicle_interaction'), value = 'vehicle_interaction'},
			{label = _U('object_spawner'), value = 'object_spawner'}
	}}, function(data, menu)

and change it to:

	ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'police_actions', {
		title    = 'Police',
		align    = 'right',
		elements = {
			{label = _U('citizen_interaction'), value = 'citizen_interaction'},
			{label = _U('vehicle_interaction'), value = 'vehicle_interaction'},
			{label = _U('toggle_duty'), value = 'toggle_duty'}, -- adds the line toggle duty
			{label = _U('object_spawner'), value = 'object_spawner'}
	}}, function(data, menu)
  1. Then scroll down a bit more and add:
elseif data.current.value == 'toggle_duty' then
			local elements = {
				{label = _U('toggle'), value = 'toggle'}
			}

			ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'toggle_duty', {
				title    = _U('toggle_duty'),
				align    = 'right',
				elements = elements
			}, function(data2, menu2)
				local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
				local action = data2.current.value

				if action == 'toggle' then
					TriggerServerEvent('esx_advanced_duty:changeDutyStatus')
				end
			end, function(data2, menu2)
				menu2.close()
			end)	

If youā€™re unsure where to put it, hereā€™s an example:

if data.current.value == 'citizen_interaction' then
	local elements = {
		{label = _U('id_card'), value = 'identity_card'},
		{label = _U('search'), value = 'search'},
		{label = _U('handcuff'), value = 'handcuff'},
		{label = _U('drag'), value = 'drag'},
		{label = _U('put_in_vehicle'), value = 'put_in_vehicle'},
		{label = _U('out_the_vehicle'), value = 'out_the_vehicle'},
		{label = _U('unpaid_bills'), value = 'unpaid_bills'}
	}

	if Config.EnableLicenses then
		table.insert(elements, {label = _U('license_check'), value = 'license'})
	end

	ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'citizen_interaction', {
		title    = _U('citizen_interaction'),
		align    = 'right',
		elements = elements
	}, function(data2, menu2)
		local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
		if closestPlayer ~= -1 and closestDistance <= 3.0 then
			local action = data2.current.value

			if action == 'identity_card' then
				OpenIdentityCardMenu(closestPlayer)
			elseif action == 'search' then
				OpenBodySearchMenu(closestPlayer)
			elseif action == 'handcuff' then
				TriggerServerEvent('esx_policejob:handcuff', GetPlayerServerId(closestPlayer))
			elseif action == 'drag' then
				TriggerServerEvent('esx_policejob:drag', GetPlayerServerId(closestPlayer))
			elseif action == 'put_in_vehicle' then
				TriggerServerEvent('esx_policejob:putInVehicle', GetPlayerServerId(closestPlayer))
			elseif action == 'out_the_vehicle' then
				TriggerServerEvent('esx_policejob:OutVehicle', GetPlayerServerId(closestPlayer))
			elseif action == 'license' then
				ShowPlayerLicense(closestPlayer)
			elseif action == 'unpaid_bills' then
				OpenUnpaidBillsMenu(closestPlayer)
			end
		else
			ESX.ShowNotification(_U('no_players_nearby'))
		end
	end, function(data2, menu2)
		menu2.close()
	end) -- add the elseif under here, like this
elseif data.current.value == 'toggle_duty' then -- paste the code here
	local elements = {
		{label = _U('toggle'), value = 'toggle'}
	}

	ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'toggle_duty', {
		title    = _U('toggle_duty'),
		align    = 'right',
		elements = elements
	}, function(data2, menu2)
		local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
		local action = data2.current.value

		if action == 'toggle' then
			TriggerServerEvent('esx_advanced_duty:changeDutyStatus')
		end
	end, function(data2, menu2)
		menu2.close()
	end)	



  1. Lastly go to esx_policejob > locales > en.lua (or whatever language youā€™re using) and add:
  ['toggle_duty'] = 'toggle Duty',
  ['toggle'] = 'toggle On/Off',

And thatā€™s it, hope this helps anyone who is looking for this.

I also suggest removing the duty marker positions in esx_advanced_duty > config.lua to avoid any issues.