Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(0)
- local playerCoords = GetEntityCoords(PlayerPedId())
- for k,doorID in ipairs(Config.DoorList) do
- local distance
- if doorID.doors then
- distance = #(playerCoords - doorID.doors[1].objCoords)
- else
- distance = #(playerCoords - doorID.objCoords)
- end
- local isAuthorized = IsAuthorized(doorID)
- local maxDistance, size, displayText = 1.25, 1, _U('unlocked')
- if doorID.distance then
- maxDistance = doorID.distance
- end
- if distance < 50 then
- if doorID.doors then
- for _,v in ipairs(doorID.doors) do
- FreezeEntityPosition(v.object, doorID.locked)
- if doorID.locked and v.objYaw and GetEntityRotation(v.object).z ~= v.objYaw then
- SetEntityRotation(v.object, 0.0, 0.0, v.objYaw, 2, true)
- end
- end
- else
- FreezeEntityPosition(doorID.object, doorID.locked)
- if doorID.locked and doorID.objYaw and GetEntityRotation(doorID.object).z ~= doorID.objYaw then
- SetEntityRotation(doorID.object, 0.0, 0.0, doorID.objYaw, 2, true)
- end
- end
- end
- if distance < maxDistance then
- if doorID.size then
- size = doorID.size
- end
- if doorID.locked then
- displayText = _U('locked')
- end
- if isAuthorized then
- displayText = _U('press_button', displayText)
- end
- ESX.Game.Utils.DrawText3D(doorID.textCoords, displayText, size)
- if IsControlJustReleased(0, 38) then
- if isAuthorized then
- doorID.locked = not doorID.locked
- TriggerServerEvent('esx_doorlock:updateState', k, doorID.locked) -- Broadcast new state of the door to everyone
- end
- end
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement