Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can add "keys" to other jobs #1

Open
Bartixxx32 opened this issue Sep 16, 2019 · 1 comment
Open

How can add "keys" to other jobs #1

Bartixxx32 opened this issue Sep 16, 2019 · 1 comment

Comments

@Bartixxx32
Copy link

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?

@iTzCrutchie
Copy link
Contributor

iTzCrutchie commented Sep 30, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants