Door Lock

Step-by-step installation guide, common issues & solutions, code snippets, error codes, config previews, locales previews, SQL previews, and changelogs; all in 1 easily accessible place.

Buy Here

FiveM Forums Post

YouTube Walkthrough Video

Translate

INSTALLATION GUIDE

Step 0 - First Steps

1. Download your resource from FiveM’s Keymaster.

2. Unzip the cd_doorlock.zip folder and place this folder in your server's resource folder.

3. Add the resource to your server start config (server.cfg): ensure cd_doorlock. If you are using a framework, it must be placed anywhere below your framework resource e.g., es_extended, not above.

ensure es_extended
ensure cd_doorlock

Step 1 - Fxmanifest

Depending on your framework and dependencies, you may need to make some changes to the [cd_doorlock/fxmanifest.lua]. We have made this easier by commenting on the lines you possibly need to change.

Step 2 - Configure Resource

You MUST read all configurable options inside the [cd_doorlock/configs/config.lua] file and configure them to suit your server's needs. Please read the ”commented out help text” at the end of each line so you can understand what each config option does.

The most important sections are the options under the Framework and Important sections at the top of the config.lua. Everything else is optional.

NEW: Auto Framework Detect!

Introducing our new 'auto_detect' feature! It automatically identifies your framework and applies the appropriate default settings.

All of the configurations for doors are done through the UI in the game;- not through a database, text files or configs.

Step 3 - Configure Key Binds

Before starting this resource on your main/live server, we highly advise configuring your key binds because this resource uses Fivem's Key Mapping.

Where can I configure my key binds?

You can configure key binds in the Keys and Commands section near the bottom of the [cd_doorlock/configs/config.lua].

Why do I need to do this?

Well long story short;- once a player has joined your server with this resource running you can no longer force change their key binds for this resource through the config.lua, only they can change it in the in-game pause menu settings. Although it will change for the players who join after you have changed it.

The benefit of this system is that it's much more optimised and players can easily change their key binds on keyboards or controllers. You can also check out the Default Keybinds for this resource.

Step 4 - Move the JSON Files

Is this your first time installing this script?

YES = You MUST do this step, or the script will not work.

No = DO NOT do this step, as you will lose your entire server's doors.

  1. Go to the [cd_doorlock/JSON files/INSTALLATION STEP FROM DOCS] folder.

  2. Copy the 2 JSON files [door_data.json] and [location_groups.json] and the 1 folder [gabz_locations].

  3. Paste them into the [JSON files] folder. It's as simple as that.

VIDEO GUIDE

AFTER EXAMPLE

Why do we do this?

Because the door_data.json and the other JSON files contain your server's door data (basically your door database). When existing customers update to a new version, we don't want you to accidentally overwrite your saved door data.

OPTIONAL FEATURES

This section is to help you understand how the built-in features of this resource work and, if applicable, how you can make them compatible with other resources. These features are not required; they are optional and can be configured in the [configs/config.lua].

Importing Gabz Maps

This script is made as simple to use as possible; therefore, all doors for every Gabz Map come pre-configured. You can choose which map you want to import the door lock files for, and the script will set them up automatically. You can have 500+ doors fully configured with just a few clicks. Ensure you enter the door permissions to set the default permissions for the doors.

Creating New Doors

New doors can only be created in-game through the UI using the /doorlockui chat command.

Editing Door Configuration

Editing door configurations can only be done in-game through the UI using the /doorlockui chat command. There are 2 ways to choose which door to edit.

Option 1 - Choose a door to edit using the search bar on the UI.

Option 2 - Choose a door to edit using our target system.

When using this method, the door MUST be fully closed when selecting a door to edit. For gates and garage doors, it's advised to lock the door first.

Deleting Doors

From this tab on the UI in-game, you can easily delete door locks for individual doors or delete the whole maps door locks with a single click (a location group). (eg., the 100+ doors for Bolingbroke prison can be deleted instantly with a single click). The delete option is only visible to admins.

Creating New Import Files

What is the purpose of creating new import files?

This is completely optional but can be helpful in some situations, such as being able to add/remove door locks from an MLO with a single click while the server is live or being able to send your friend pre-configured door locks for an MLO so he can set up door locks on his server with a single click.

Step 1 - Download the template.

Step 2 - Make a backup of your door_data.json file in [cd_garage/JSON files] folder because we must wipe your door_data.json file to do this.

Step 3 - Delete everything inside the door_data.json file, and replace it with [].

Step 4 - Go in-game and create the doors for the MLO. Make sure to use a new and unique location group.

Step 5 - After creating all the doors, copy the full code from inside the door_data.json file and paste it into the doorlock_template.json. Specifically, paste it where it says "PASTE HERE" - EXAMPLE.

Step 6 - Rename the doorlock_template.json file to whatever you like, but you must also change the "name" inside the JSON file - EXAMPLE.

Step 7 - You now have a working import file for our door lock resource. You can add it inside the gaz_locations folder, and you can import it in-game.

INFORMATION

Default Key Binds

These keys can be modified and/or disabled in the Keys and Commands section of the [configs/config.lua].

Please make sure you understand how Key Mapping works.

Key
Description

E

Open the closest door.

Chat Commands

These chat commands can be renamed and/or disabled in the Keys and Commands section of the [configs/config.lua].

The exact usage for each command will be displayed in the chat suggestions when using the commands in-game.

Command
Description

/doorlock

Open the closest door.

/doorlockui

Open the door lock UI to create/delete/edit doors.

Events

These events are completely optional; you can use them if needed.

Set the state of the closest door EXAMPLE

The 1st argument [state] sets the doors state (false = unlock, true = lock).
TriggerEvent('cd_doorlock:SetDoorState_closest', state)

Set the state of a specific door by name EXAMPLE

The 1st argument [state] sets the doors state (false = unlock, true = lock). The 2nd and 3rd arguments are how you define the door.
TriggerEvent('cd_doorlock:SetDoorState_name', state, 'door_name', 'location_group')

View a door's camera EXAMPLE

This event will open a specific doors door camera. The 1st and 2nd arguments are how you define the door.
local door_id = exports['cd_doorlock']:GetDoorID('door_name', 'location_group')
if door_id then
    TriggerEvent('cd_doorlock:ViewDoorCamera', door_id)
else
    print('door_does_not_exist')
end

Set new perms for a specific door EXAMPLE

This event will set new perms, overwriting the existing ones. Uncomment the lines you want to set. You can uncomment multiple lines.
local door_data = exports['cd_doorlock']:GetDoorDataFull_name('door_name', 'location_group')
if door_data then
    TriggerEvent('cd_doorlock:UpdateDoorPerms', door_data, {
        --passcode = '1234',
        --identifier = {'steam:xxxxx', 'license:xxxxx', 'fivem:xxxxx', },
        --ace = {'doorlock.police', },
        --discord = {'xxxxx', 'xxxxx', },
        --[[job = {
            [1] = {
                name = 'police',
                grade = 0,
            },
        },]]
    })
else
    print('door_does_not_exist')
end

Exports

These exports are completely optional; you can use them if needed.

Get the state of the closest door

(boolean) Returns the state of a door telling you if its locked or unlocked.
exports['cd_doorlock']:GetDoorState_closest()

Get the state of a specific door EXAMPLE

(boolean) Returns the state of a door telling you if its locked or unlocked. The 1st and 2nd arguments is how you define which door's state to get.
exports['cd_doorlock']:GetDoorState_name('door_name', 'location_group')

Get the full cached data of the closest door

(table) Returns the full cached data of a door.
exports['cd_doorlock']:GetDoorDataFull_closest()

Get the full cached data of a specific door EXAMPLE

(table) Returns the full cached data of a door. The 1st and 2nd arguments is how you define which door's data to get.
exports['cd_doorlock']:GetDoorDataFull_name('door_name', 'location_group')

Get a door's ID EXAMPLE

(number) Returns the ID of a door. Required for some events. The 1st and 2nd arguments is how you define which door's ID to get. (this id is not unique and can change).
exports['cd_doorlock']:GetDoorID('door_name', 'location_group')

COMMON ISSUES

Please check out our Troubleshooting Guide before contacting our support.

🔔 Folder Name Make sure the name of the folder either cd_doorlock.

🔔 Encrypted Files Do not edit the encrypted files in any way.

On the UI only 2 tab’s are showing not 4?

eg., you are an admin but only the Control and Settings tab are visible on the UI; but it should show all 4 tabs (Create/Edit, Control, Import & Settings). So you are unable to create new doors or import doors.

✔️ This is because you don’t have admin permissions set up correctly on your server. There could be multiple reasons for this.

1. The Config.AdminAccess in the config.lua has not been configured correctly for your server.

2. If you use ESX or QBCORE your players permissions are set up incorrectly through your framework. This is nothing to do with this script.

3. If you are using the Standalone framework option, and you have enabled Ace Perms; the ace perms are most likely not set up correctly in your server.cfg. To confirm this is the issue you can change the script to use the "command" ace perm and if the doors work then this is your issue, as the "command" ace perm gives every player access.

4. If you are using the Standalone framework option, and you have enabled Discord Perms; badger discord perms is required and it must be named [Badger_Discord_API].

New doors don’t save (using ZAP-Hosting)?

eg., if you use ZAP-Hosting, and you create new doors but they don’t save after a script/server restart.

✔️ This is because data is not being written to JSON file’s due to permission issues. (Only for people using zap-hosting).

Follow the following steps.
1. Stop the server.
2. Move the files to your server using filezilla or winscp.
3. Set the permissions for all JSON files to read write and execute for owner, group and user - https://www.pipeten.com/support/scripting/changing-file-permissions-using-filezilla/.
4. Then start the server.

Can't find a gate/garage door when using the "Edit Selected" button?

eg., if you try to edit a gate/garage door using our target system using the edit selected button and see this error: "This door is not in the system. Please create one first".

✔️ This is because the coords of the gate/garage door has changed due to it being open. Simply lock the gate/garage door and try again and it will work.

ERROR CODES

If you see an error code not listed below, please open a script support ticket in the Codesign Discord.

0001/0002 - The simple answer is that you did not complete Step 4 - Move the JSON Files of the installation guide.

7854 - You are pressing E to interact with a door, but no doors are nearby. It's possible you are out of range of the door, so get closer.

3001 - You are pressing E to interact with a door, but no doors have been created/imported yet.

6035 - One or more of your items in the Config.LockpickItems.lockpick_items table in the config.lua is not a valid item in your framework.

0427 - You have not completed Step 1 - Fxmanifest correctly. You must go into the fxmanifest.lua and uncomment the line for ox_lib.

CHANGELOG

Files Changed

Not every update requires you to replace the whole folder. We do this because we understand it's a pain to redo the configs for every update.

  • All Files - This means you should make a backup of the JSON Files folder, delete your old cd_doorlock folder, download and add in the latest version, replace the new JSON Files folder with the one you made a backup of, configure the configs folder and restart your server.

  • All Files Except config.lua - This means you should do all of the above (in the All Files section) but additionally make a backup of the config.lua file and replace the new config.lua file with the one you made a backup of.

  • Specific Files - This means you can copy and paste the SPECIFIC new files over the old ones and restart the server.

Update Type

On rare occasions, you are forced to update to the latest version. Mostly due to authentication updates where the old versions will no longer work.

  • Mandatory - This means you MUST update to this new version, or the old versions will no longer work.

  • Optional - This means it's completely your choice whether you wish to update to the latest version. But we do not offer support for old versions for obvious reasons; they are old.

PLEASE READ! (JSON files)

When updating a resource that uses JSON files as a database as this one does, DO NOT delete/replace the files/folders inside the JSON files folder, as this will delete/overwrite your saved database.

Skipping Updates

If you are attempting to update to the latest version but have skipped previous updates, you should update all files just to be safe. For example., let's say you are currently on v4.0.1, you did not update when v4.0.2 was released, and now v4.0.3 is released, and you want to update; you should always use the “All Files” update method.

05/10/2022

Files Changed:

Update Type:

Changelog:

STATUS

  • Development Stage: COMPLETE

  • Alpha Test Stage: COMPLETE

  • Beta Test Stage: COMPLETE

Last updated

Logo

Codesign Software © All rights reserved