Back to Blog
Tutorial 10 min read October 18, 2025

FiveM Door Lock Script Guide: Securing Interiors for QBCore & ESX (2026)

How door lock scripts work in FiveM, setup guides for popular options like ox_doorlock and qb-doorlock, configuring permissions by job and item, and troubleshooting common issues.

door lock script fivem fivem door lock script door lock script fivem qbcore fivem doorlock script ox_doorlock qb-doorlock

What Is a Door Lock Script?

A door lock script controls who can open and close doors throughout your FiveM server. Without one, every door in the game world is either permanently open or permanently closed at its default state. Door scripts let you:

  • Lock police station doors so only officers can enter
  • Lock business interiors to job-specific employees
  • Create key-based access for housing
  • Allow criminals to lockpick secured locations
  • Control access to restricted areas (jail, government buildings, VIP zones)

Door locks are one of the most fundamental scripts on any RP server. They are required by many other scripts (housing, jobs, businesses) as a dependency.


How Door Lock Scripts Work

GTA V Door System

GTA V has built-in door entities that can be controlled via natives:

  • DoorSystemSetDoorState — Lock or unlock a door by its hash
  • DoorSystemSetAutomaticRate / DoorSystemSetAutomaticDistance — Control auto-open behavior

Each door in GTA V has a model hash and exists at specific coordinates. Door lock scripts identify doors by their hash + coordinates combination.

Door Identification

Finding the correct door hashes is one of the most tedious parts of FiveM development. Methods include:

  1. In-game debug tools — Scripts that display the model hash of the nearest door
  2. Door hash databases — Community-maintained lists of common door hashes organized by location
  3. Raycast detection — Point at a door and the script reads its entity info

Lock States

StateBehavior
UnlockedAny player can open the door normally
LockedDoor cannot be opened (solid, immovable)
RestrictedOnly authorized players can open it (job, item, or key-based)
Auto-lockDoor relocks after a configurable time period

ox_doorlock (Overextended)

ox_doorlock is the most widely used door lock system in 2026. Key features:

  • Framework agnostic — Works with ESX, QBCore, and standalone setups via ox_lib
  • In-game editor — Create and configure new door locks directly in-game without editing config files
  • Permission types — Lock by job, job grade, item, citizenid/license, or group
  • Auto-lock — Doors re-lock after a configurable delay
  • Lockpick support — Integration with lockpicking scripts
  • Double doors — Supports paired doors that open/close together
  • Performant — Optimized with minimal resource usage

The in-game editor is the standout feature: point at a door, run a command, and define its lock settings through a menu — no server restart needed.

qb-doorlock

The default door lock system for QBCore servers:

  • QBCore-native — Uses QBCore exports and player data directly
  • Config-based — Doors are defined in a config file with coordinates, hashes, and permissions
  • Job restrictions — Lock doors by job name and minimum grade
  • Item restrictions — Require a specific item (key card, key) to unlock
  • Shared keys — Multiple players can have access to the same door

The main limitation is config-based setup — every door must be added manually to the config file with its exact hash and coordinates.

esx_doorlock

The ESX equivalent, offering similar functionality: config-based door definitions, ESX job-based permissions, and event-driven lock/unlock system.


Prerequisites: ox_lib installed, oxmysql for database storage.

Installation Steps:

  1. Download ox_doorlock from GitHub
  2. Place in resources folder
  3. Import the SQL file into your database
  4. Add ensure ox_doorlock to server.cfg (after ox_lib and oxmysql)
  5. Grant admin permissions for the in-game editor

Adding Doors In-Game:

  1. Navigate to the door you want to lock
  2. Open the admin menu (configured command)
  3. The script auto-detects the nearest door and its hash
  4. Set permissions — choose job, grade, item, or ACE group requirements
  5. Configure auto-lock (optional)
  6. Save — the door is now locked and persisted in the database

Common Configuration Patterns

Police Station

Lock all PD doors to police job, with different grades for different areas:

AreaRequired JobMinimum GradeReason
Front entrancepolice0 (any rank)General access
Armorypolice2 (Sergeant+)Restrict weapon access
Evidence roompolice3 (Lieutenant+)Sensitive materials
Chief's officepolice4 (Chief only)Private office

Hospital

AreaAccessMethod
Main entranceEveryoneUnlocked always
Staff areasambulance jobJob restriction
Pharmacyambulance grade 2+Grade restriction
Morgueambulance or policeMulti-job restriction

Business Interiors

For player-owned businesses, use item-based locks (business key) or citizenid locks (owner identifier) rather than job locks.


Lockpicking Integration

Door lock scripts usually support lockpicking for criminal gameplay:

  • A player uses a lockpick item on a locked door
  • A minigame starts (timing-based, skill check, etc.)
  • Success: Door unlocks temporarily
  • Failure: Lockpick may break (consumed), alert may trigger for police

This creates dynamic interaction between locked doors and criminal RP — police lock things down, criminals try to break in.


Performance

ScriptApproachTypical Resmon
ox_doorlockSpatial indexing, streamed approach0.00-0.01ms
qb-doorlockDistance loop per configured door0.01-0.05ms (depends on door count)
esx_doorlockSimilar to qb0.01-0.05ms

For servers with 100+ configured doors, ox_doorlock's optimized approach is recommended. Config-based scripts that loop through every door entry can show higher resmon with large door counts.


Troubleshooting

IssueCauseFix
Door does not lock/unlockWrong door hashUse in-game debug to verify the exact hash
Double door only one side worksOnly one door configuredAdd both door hashes to the config
Lock state does not persist after restartDatabase not connectedVerify SQL import and database connection
Authorized player cannot openJob name mismatchCheck exact job name in framework vs script config
Everyone can open locked doorsScript loaded before frameworkEnsure door script loads after your framework

→ Browse All Scripts | → FiveM Script Installation Guide

Ready to Transform Your Server?

FiveM Job Creator eliminates every problem discussed in this article. 0.00ms resmon. No-code configuration. ESX & QBCore native.

Get Job Creator on Tebex — €29.99