TheBritishBrotherhood/esx_dnaDoorManager

How can add "keys" to other jobs

Opened this issue · 1 comments

Hey i tried

if xPlayer.job.name ~= 'police' or xPlayer.job.name ~= 'ambulance'  then

and it didnt worked :/ how can i add a ablity to EMS to open doors?

So this requires a little bit of code editing to fix. First ill explain whats happening. The way it is set up is it checks the requirement then executes the code. Since this is ~= police that means the code is done and it will continue with the rest of the code since ambulance does not equal police. It will not move to the ~= ambulance as the requirement to continue the code has already been met with ~= police. In order to get this to work you will need to edit the following on the server side.

Lines 13-20 From:

        if isDoorLocked == 1 then
            if xPlayer.job.name ~= 'police' then
                TriggerClientEvent("doormanager:c_noDoorKey", _source, doorId)                     
            else
                TriggerClientEvent("doormanager:c_openDoor", -1, doorId)
                SetDoorStatus(doorId,0) 

            end

To:

        if isDoorLocked == 1 then
            if xPlayer.job.name == 'police' or xPlayer.job.name == 'ambulance' then
               TriggerClientEvent("doormanager:c_openDoor", -1, doorId)
               SetDoorStatus(doorId,0)                 
            else
	       TriggerClientEvent("doormanager:c_noDoorKey", _source, doorId)
            end

And then you will need to edit the close door server function as well at lines 31-37.
From:

    if isDoorLocked == 0 then
        if xPlayer.job.name ~= 'police' then
            TriggerClientEvent("doormanager:c_noDoorKey", _source, doorId)
        else
            TriggerClientEvent("doormanager:c_closeDoor", -1, doorId)
            SetDoorStatus(doorId,1)       
        end

To:

    if isDoorLocked == 0 then
        if xPlayer.job.name == 'police' or xPlayer.job.name == 'ambulance' then
            TriggerClientEvent("doormanager:c_closeDoor", -1, doorId)
            SetDoorStatus(doorId,1) 

        else
	     TriggerClientEvent("doormanager:c_noDoorKey", _source, doorId)      
        end

This way it checks to see if you are police. If that check fails THEN it moves to the next part of the check which is to see if you are in the ambulance job. If both of those fail then it will say you have no key and not unlock the door.

This is testing and working on my server.

I am actually going to try to work on getting this client side and working with authorized jobs for each individual door. If i get it working and functional and not causing massive MS issues then I will generate a PR.