[ESX] On / Off Duty Script

Make a player class in esx for onduty. It would be true or false.

Works great! Many thanks!!

But is it just me or recruits can’t go off duty? Any other class can… :confused:

Edit.: @qalle, pls, update your server/main.lua for recruit, so he can go off duty as well:

if xPlayer.job.name == 'police' and xPlayer.job.grade == 0 then
    xPlayer.setJob('offpolice', 0)
elseif xPlayer.job.name == 'police' and xPlayer.job.grade == 1 then
    xPlayer.setJob('offpolice', 1)
elseif xPlayer.job.name == 'police' and xPlayer.job.grade == 2 then
    xPlayer.setJob('offpolice', 2)
elseif xPlayer.job.name == 'police' and xPlayer.job.grade == 3 then
    xPlayer.setJob('offpolice', 3)
elseif xPlayer.job.name == 'police' and xPlayer.job.grade == 4 then
    xPlayer.setJob('offpolice', 4)
end

if xPlayer.job.name == 'offpolice' and xPlayer.job.grade == 0 then
    xPlayer.setJob('police', 0)
elseif xPlayer.job.name == 'offpolice' and xPlayer.job.grade == 1 then
    xPlayer.setJob('police', 1)
elseif xPlayer.job.name == 'offpolice' and xPlayer.job.grade == 2 then
    xPlayer.setJob('police', 2)
elseif xPlayer.job.name == 'offpolice' and xPlayer.job.grade == 3 then
    xPlayer.setJob('police', 3)
elseif xPlayer.job.name == 'offpolice' and xPlayer.job.grade == 4 then
    xPlayer.setJob('police', 4)
end

Thanks again for this great resource!! :slight_smile:

3 Likes

so i am getting only the off duty from pnotify and nothing happens

1 Like

You’ve added the sql?

yes it was sql duplicates ,working fine now

I have DRDoors, and using this I thought I would be able to get it to where I can go on duty so I can open the mission row doors so I can access the locker room. But it clocks me in as LSPD Captain, and I can’t open doors. any ideas?

I also use Cops_FiveM

Why are you uisng Cops_Fivem when you have esx_policejob?

I deleted ESX_PoliceJob and wasn’t using it at the time, but now I am using it instead of Cops_FiveM. It’s still not working, am I missing something?

This is for esx_policejob if you have other ranks than that job you will need to change them yourself in server.lua

Is there a way to add more locations?

It will send someone working the original script you need to rework

Hi nice script,

i have a problem when i want to go on duty it message me:

onduty
and directly after that
offduty

if im police i can go off or on duty aswell @ Ambulance and as @ambulance i can get/off asswel @ police office

Anyone has any ideas?

i am wondering if there is a way to make it so when you go off duty it gives you back you CIV clothes and on duty gives you the EMS clothes??

i know it is possible just unsure how to implement

2 Likes

thats not the way to do it … you should clientsided enable phone when someone is on duty and off dute disaple phone, not create new job ressource …

would this work with copsfivem?

1 Like

I get this error when going on as a cop

es_extended: TriggerServerCallback => [esx_service:isInService] does not exist

@ikrazy

This is based on ESX, copsfivem are not ESX related. It won’t work

@Jason1123

You’re missing esx_service

I found it. Thats exactly what it was. i noticed it a few hours after mentioning it.

Somehow it got removed from my files.