🔑 Physical Keys
Requirements
- ox_inventory - Physical keys only work with ox_inventory. If you use a different inventory system, physical keys will be automatically disabled.
Configuration
Enable physical keys in your config.lua:
luaPhysicalKeys = { Enabled = true, -- Enable physical key system ItemName = 'housing_key', -- The item name for physical keys BittingCodeLength = 5, -- Length of the random bitting code portion KeyTypes = { MainEntrance = true, -- Keys for main property entrance (Shell/IPL) InteractablePoints = true, -- Keys for individual interactable points Doors = true, -- Keys for individual MLO doors MasterKey = true, -- Master key that unlocks everything }, AllowRekey = true, -- Allow changing lock cylinders RekeyPrice = 500, -- Cost to re-key a lock },
Adding Items to ox_inventory
Add the following items to your ox_inventory/data/items.lua:
lua['housing_key'] = { label = 'Property Key', weight = 50, stack = false, close = true, description = 'A key for a property lock', consume = 0, }, ['key_wax'] = { label = 'Key impressioning wax', description = 'Use this to impression keys. Impressioning is the process of creating a copy of a key by pressing it into wax.', weight = 10, consume = 0, unique = true, client = { image = 'key_wax.png', } }, ['key_wax_used'] = { label = 'Used key impressioning wax', description = 'Use this to impression keys. Impressioning is the process of creating a copy of a key by pressing it into wax.', weight = 10, consume = 0, unique = true, client = { export = 'nolag_properties.getBittingCode', image = 'key_wax.png', } },
Key Types
Main Entrance Key (E)
- Available for Shell and IPL properties
- Unlocks the main entrance door
Interactable Point Key (P)
- Available for all property types
- Unlocks specific interactable points (inventory, wardrobe, etc.)
Door Key (D)
- Available for MLO properties
- Unlocks specific doors within the property
Master Key (M)
- Available for all property types
- Unlocks all doors and interactable points on the property
Bitting Code Format
Each key has a unique bitting code that identifies which lock it opens:
PPPPPP_T_LLLL_RRRRR
PPPPPP- Property ID (6 digits, zero-padded)T- Lock Type (E=Entrance, P=Point, D=Door, M=Master)LLLL- Lock ID (4 digits, zero-padded)RRRRR- Random code (5 digits by default)
Example: 000001_E_0000_63323 means:
- Property ID: 1
- Lock Type: Entrance
- Lock ID: 0
- Random Code: 63323
Re-keying
When a lock is re-keyed:
- A new bitting code is generated
- All existing keys for that lock become invalid
- New keys must be issued with the new bitting code
This simulates changing the lock cylinder in real life.
Managing Keys
Keys can be managed through the property management menu:
- Open the property management menu
- Go to the "Physical Keys" tab
- Select a lock to issue keys or re-key
Exports
The following exports are available for integration:
lua-- Check if physical keys are enabled local enabled = exports.nolag_properties:PhysicalKeys_IsEnabled() -- Check if a player has a valid key local hasKey = exports.nolag_properties:PhysicalKeys_PlayerHasKey(source, propertyId, lockType, lockId) -- Issue a key to a player local success, error = exports.nolag_properties:PhysicalKeys_IssueKey(source, propertyId, lockType, lockId) -- Validate a key metadata against a lock local valid = exports.nolag_properties:PhysicalKeys_ValidateKey(keyMetadata, propertyId, lockType, lockId) -- Re-key a lock local newCode, error = exports.nolag_properties:PhysicalKeys_RekeyLock(propertyId, lockType, lockId) -- Get all available locks for a property local locks = exports.nolag_properties:PhysicalKeys_GetAvailableLocks(propertyId)