On Duty / Off Duty Panic Button Script

Hey there!
Came freshly from SQF (Arma 3) to FiveM and looking for improving some of our Police-RP.

I’m using the Duty System by qalle
and additionally im using the Police Panic by ChristopherM.

I don’t want the Officers to need to tune in every time into the Panic Channel and also do not want to add each Officers one by one to the Config.

So i tried, combining the Duty System together with the Ressource.
I came this far:
The Panic Command i limited to the “police” job, since they will be offduty with the “offpolice” job.

-- /panic command
RegisterCommand("panic", function()
	if ESX.PlayerData.job.name == 'police' then

and limited the panictune command aswell to the Person with the “police” job.

-- /panictune command
RegisterCommand("panictune", function()
	if ESX.PlayerData.job.name == 'police' then

Now, When i go on Duty he should register that the Person is on Duty, right?
Still Outputs that “You’re not in Duty” (Custom Set Message for this) and does not tune in the Channel nor does he have Permission to execute the “/panic”, “/panictune” Command or use any of the Items / Menu Options, Custom Made for the Panic Button.

Is there a way, to automatically tune him into the Panic Channel when going On-Duty and Tune him out of the Panic Channel when going Off-Duty?

Maybe, this even works better when using the Advanced Duty System by Nosmakos?

Thank you so much for your Help in Advance.

Best Regards,



Got it working so far by switching to the Advanced Duty System by Nosmakos.

I’ve added to the client.lua of the Panic Button Ressource:

ESX = nil
local PlayerData = {}                                                                                                  
    while ESX == nil do
        TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
	while ESX.GetPlayerData().job == nil do

    ESX.PlayerData = ESX.GetPlayerData()

AddEventHandler('esx:setJob', function(job)
    PlayerData.job = job

and added following to the Commands:

if PlayerData.job ~= nil and PlayerData.job.name == 'police' then

Now - Can i just tell the Duty Script to execute PanicTune() while going on Duty, or do i need to import the Panic Ressource?

1 Like

You can probably remove the tune command altogether and just replace this line with an ESX Job check for Police:

Hey ChristopherM,

Thanks for your Reply!
That helped and worked like charm.

To combine everything together with the Duty System, I’ve added a Eventhandler to the esx:setJob Event:

-- /panictune command
--RegisterNetEvent("panictune", function()
--	if PlayerData.job ~= nil and PlayerData.job.name == 'police' then
--		PanicTune()
--		else
--		NewNoti("~r~Du bist nicht im Dienst!", true)
--	end
AddEventHandler("esx:setJob", function ()
	if PlayerData.job ~= nil and PlayerData.job.name == 'police' then
			NewNoti("~r~Du bist nicht im Dienst und dich erreichen keine Notrufe mehr!", true)

And now this works like a Charm. Thank you very much!

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