[Release] esx_doorlock

How do I add so 2 jobs can open the same door

Funny with this mod you can effectively become carjammed (stuck in cars and unable to get out). Might be due to a server-sided bug or not, but I noticed it happening on a variety of servers I played on recently

Is there anyway to sync the doors to everyone that they are locked even if they are not near it ? If im 20 feet from a door i can shoot it open and break someone out of jail

1 Like

Possible to add a door that has an unknown name? I’ve got the hash and ID but when I go to Map Editor the name of the doors are unknown?

Have you tried using codewalker? @Keith_Dave

Good job

@Hawaii_Beach

How can I add jjobs?

authorizedJobs = { ‘police’ }, { 'fbi },

or

authorizedJobs = { ‘police’, ‘fbi’ },

or

What?

just use the authorizedJobs = { ‘police’ }

Oh my god…

I need add more jobs man

well isn’t fbi police anyways lol

Hey @Hawaii_Beach how can I change the font of the text? ([E] Locked / [E] Unlocked)

has someone here coords for other doors i can add like bahama tequilala bikers club etc?

Sure I can write a tutorial on how to add new doors.

1 Like

Would be sick . I am trying to add some more new doors . Specially for FIB , Mafia etc . My Problem atm is that i dont know how i get through a door if i unlocked it since its still like a wall for me . I can see the interior but not go in it :wink: Kepp up the good work.

@Hawaii_Beach When i lock the route 68 repair/mechanic shop garage doors, the doors are locked when run up to the place, but if you unlock and lock them they glitch.
I used the coordinates and models posted in these links

You identify the door here: https://wiki.■■■■■■■■■■■/index.php?title=Doors
And find the prop name here: https://github.com/Guad/MapEditor/blob/master/ObjectList.ini

2 Likes

How do i get accurate coords for the doors. Trying to add a locked gate on one of my houses but can’t seem to get the exact coords to the item

1 Like

@Hawaii_Beach I got all the door i want and i edited the collision file so there is nothing but if i move through the door the old model is still showing . It looks like the old and new door are rendering and it looks scuffed . Can i somehow remove the static old door so you only see the moving dynamic one ? Would be cool if someone can help with that :wink:

To get this working for EMS and Police, you’ll need to make the following adjustments to your server and client main.lua files.

Server Main.lua

ESX = nil

TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)


RegisterNetEvent("esx_walkie:startActionB")
AddEventHandler("esx_walkie:startActionB", function()
	local xPlayers = ESX.GetPlayers()

		for i=1, #xPlayers, 1 do

			local xPlayer = ESX.GetPlayerFromId(xPlayers[i])

			if xPlayer.job.name ~= nil and (xPlayer.job.name == "police" or xPlayer.job.name == "ambulance") then
				TriggerClientEvent("esx_walkie:startAnim", xPlayer.source) -- Client Event auf Animatonen start
				TriggerClientEvent("esx_walkie:startActionB", xPlayer.source) -- Client Event auf Aktionen start
				
			end
		end
end)

RegisterNetEvent("esx_walkie:stopActionB")
AddEventHandler("esx_walkie:stopActionB", function()
	local xPlayers = ESX.GetPlayers()

		for i=1, #xPlayers, 1 do

			local xPlayer = ESX.GetPlayerFromId(xPlayers[i])

			if xPlayer.job.name ~= nil and (xPlayer.job.name == "police" or xPlayer.job.name == "ambulance") then
				TriggerClientEvent("esx_walkie:stopAnim", xPlayer.source) -- Client Event auf Animatonen start
				TriggerClientEvent("esx_walkie:stopActionB", xPlayer.source) -- Client Event auf Aktionen start

			end
		end
end)

RegisterServerEvent('esx_walkie:playSoundWithinDistanceServer')
AddEventHandler('esx_walkie:playSoundWithinDistanceServer', function(maxDistance, soundFile, soundVolume)
	local xPlayers = ESX.GetPlayers()

		for i=1, #xPlayers, 1 do

			local xPlayer = ESX.GetPlayerFromId(xPlayers[i])

			if xPlayer.job.name ~= nil and (xPlayer.job.name == "police" or xPlayer.job.name == "ambulance") then
				TriggerClientEvent('esx_walkie:playSoundWithinDistanceClient', -1, xPlayer.source, maxDistance, soundFile, soundVolume)
			end
		end
end)

Client main.lua

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(1)
        if IsControlPressed(2, Keys["M"]) and GetLastInputMethod(2) and Busy == false and PlayerData.job.name ~= nil and (PlayerData.job.name == "police" or PlayerData.job.name == "ambulance") then
                TriggerServerEvent("esx_walkie:playSoundWithinDistanceServer", 10, "copradiooff", 0.7) 
                TriggerServerEvent("esx_walkie:startActionB") -- Aktion für andere Personen starten
                DisableActions(GetPlayerPed(-1))
                TriggerEvent("esx_walkie:startAnim", source)
                Busy = true
            -- Aktiviere esx_walkie Talkie
        elseif not IsControlPressed(2, Keys["M"]) and GetLastInputMethod(2) and Busy == true and PlayerData.job.name ~= nil and (PlayerData.job.name == "police" or PlayerData.job.name == "ambulance") then
            -- Deaktiviere esx_walkie Talkie
                TriggerServerEvent("esx_walkie:playSoundWithinDistanceServer", 10, "copradio", 0.7) 
                TriggerServerEvent("esx_walkie:stopActionB") -- Aktion für andere Personen stoppen
                EnableActions(GetPlayerPed(-1))
                TriggerEvent("esx_walkie:stopAnim", source)
                Busy = false
            else
        end
    end
end)

Only issue is that they share the same voice channel, so for roleplay purposes you’ll probably need to enforce a callouts prior or messages used.

(also I’m using a modified key “M” because default PTT is N. Feel free to change)

So, I changed my code a little bit and made it only possible to lock doors when they are closed or if you lock the door while open they will close and then lock.

If you want to make it that they only lock in the closed status you need to replace

function ApplyDoorState(doorID)
	local closeDoor = GetClosestObjectOfType(doorID.objCoords.x, doorID.objCoords.y, doorID.objCoords.z, 1.0, GetHashKey(doorID.objName), false, false, false)
FreezeEntityPosition(closeDoor, doorID.locked)

with

function ApplyDoorState(doorID)
	local closeDoor = GetClosestObjectOfType(doorID.objCoords.x, doorID.objCoords.y, doorID.objCoords.z, 1.0, GetHashKey(doorID.objName), false, false, false)
		
	if doorID.locked == false then
        NetworkRequestControlOfEntity(closeDoor)
        FreezeEntityPosition(closeDoor, false)
    else

	local locked, heading = GetStateOfClosestDoorOfType(GetHashKey(doorID.objName), doorID.objCoords.x,doorID.objCoords.y,doorID.objCoords.z, locked, heading)
    if heading > -0.02 and heading < 0.02 then
        NetworkRequestControlOfEntity(closeDoor)
        FreezeEntityPosition(closeDoor, true)
    end
	end
end

in the client side around line 88

6 Likes

Have you figured that out yet?
I tried but the doors wouldnt close even tho i can press E to close and open

1 Like