# CCTV Cameras

[**Buy Here**](https://codesign.pro/product/5501429)

[**FiveM Forums Post**](https://forum.cfx.re/t/paid-codesign-cctv-cameras/5046714)

[**YouTube Walkthrough Video**](https://youtu.be/5xUKtxSVxZA)

#### Translate

* [Click here to translate this page.](https://docs-codesign-pro.translate.goog/paid-scripts/cctv-cameras?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en&_x_tr_pto=wapp)
* [How do I change language?](https://gyazo.com/38606313ac9a7c290dc2c72b6793bde6)

## INSTALLATION GUIDE

### Step 0 - First Steps

{% hint style="warning" %}
**1.** Download your resource from [FiveM’s Keymaster](https://keymaster.fivem.net/asset-grants). &#x20;

**2.** Unzip the `cd_cctv.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_cctv`. 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_cctv
```

{% endhint %}

### Step 1 - Configure Resource

{% hint style="warning" %}
You **MUST** read all configurable options inside the **`[cd_cctv/configs/config.lua]`** file and configure them to suit your server's needs. Please read the [”commented out help text”](https://i.imgur.com/QCja8UZ.png) 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** ](https://i.imgur.com/4ukCTZr.png)**and** [**Important** ](https://i.imgur.com/IVm7E8l.png)**sections at the top of the `config.lua`. Everything else is optional.**

> [**NEW: Auto Framework Detect!**](https://i.imgur.com/zNW8Kpg.png)
>
> Introducing our new 'auto\_detect' feature! It automatically identifies your framework and applies the appropriate default settings.
> {% endhint %}

### Step 2 - Add More Camera Types

{% hint style="warning" %}
In the `[cd_cctv/configs/config.lua]` file, scroll down to the [PLACING CCTV CAMERAS](https://i.imgur.com/jUqzENG.png) section. In the  **`Config.CCTV`**  table you can configure default cameras or add new ones; everything is explained in the [”commented out help text”](https://i.imgur.com/89Vsywi.png).&#x20;
{% endhint %}

### HOW TO USE

This resource is very easy to install, configure and use. Once the steps above are complete, the rest is simple:

1. You have 2 ways to place the CCTV cameras, depending on if you use a framework. You can either use the  **`/cctv1`**  or  **`/cctv2`**  chat commands or use the **`cctv1`**  or  **`cctv2`** usable items (if you use a framework).
2. Now you have placed your camera, use the  **`/cctvui`**  chat command to open the CCTV management UI; here, you can view the cameras and give other players access to view your cameras.

##

## INFORMATION

### Chat Commands

These chat commands can be renamed and/or disabled in the [Keys and Commands](https://i.imgur.com/bTvuXLZ.png) 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                                                  |
| ------------- | ------------------------------------------------------------ |
| **`/cctvui`** | Open the cctv UI.                                            |
| **`/cctv1`**  | Place a 360° camera (with default settings in Config.CCTV).  |
| **`/cctv2`**  | Place a 180° camera (with default settings in Config.CCTV).  |
| **`/cctv3`**  | Place a fixed camera (with default settings in Config.CCTV). |

### Events

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

{% tabs %}
{% tab title="client-side to client-side" %}
**Open the CCTV management UI**

{% code title="This very simple event will open the UI where you can view your cameras and give other people access." %}

```lua
TriggerEvent('cd_cctv:OpenCCTVUI')
```

{% endcode %}
{% endtab %}

{% tab title="server-side to client-side" %}
**Open the CCTV management UI**

{% code title="This very simple event will open the UI where you can view your cameras and give other people access." %}

```lua
TriggerClientEvent('cd_cctv:OpenCCTVUI', source)
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Exports

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

{% tabs %}
{% tab title="client-side exports" %}
**Gain access to view all cameras within a distance**

{% code title="You can trigger this export in robberies for example to gain access to view all cameras for a period of time within a set distance of the coords provided. \[ coords = vector3, distance = integer, time = integer (in minutes) ]" %}

```lua
exports["cd_cctv"]:GetTemporaryAccessWithinDistance(coords, distance, time)
```

{% endcode %}

**Gain access to view a specific camera**

{% code title="You can trigger this export in robberies for example to gain access to a specific camera for a period of time. \[ camera\_id = string , time = integer (in minutes) ]" %}

```lua
exports["cd_cctv"]:GetTemporaryAccessByID(camera_id, time)
```

{% endcode %}

**Temporarily disable all cameras within a distance**

{% code title="You can trigger this export in robberies for example to disable all cameras for a period of time within a set distance of the coords provided. \[ coords = vector3, distance = integer, time = integer (in minutes) ]" %}

```lua
exports["cd_cctv"]:DisableCamerasInDistance(coords, distance,  time)
```

{% endcode %}

**Temporarily disable a specific camera**

{% code title="You can trigger this export in robberies for example to disable a specific camera for a period of time. \[ camera\_id = string , time = integer (in minutes) ]" %}

```lua
exports["cd_cctv"]:DisableCameraById(camera_id, time)
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Usable Items

Usable items can be renamed or disabled in the `[configs/config.lua]`. You can also add more in the  **`Config.CCTV`**  table.

| Item Name   | Description                                                  |
| ----------- | ------------------------------------------------------------ |
| **`cctv1`** | Place a 360° camera (with default settings in Config.CCTV).  |
| **`cctv2`** | Place a 180° camera (with default settings in Config.CCTV).  |
| **`cctv3`** | Place a fixed camera (with default settings in Config.CCTV). |

> **Inventory Images (100x100)**

{% file src="<https://789235289-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MSKsM-AnxI2icNixJI8%2Fuploads%2FikdoLQOyDOVV6lEpo5JF%2Fcd_cctv_inventory_images.zip?alt=media&token=8e14e6fa-2137-4719-964b-43100d63f3a4>" %}

{% tabs %}
{% tab title="Add items on ESX" %}
{% code title="Run these SQL queries in your database." lineNumbers="true" %}

```sql
INSERT INTO `items` (`name`, `label`, `weight`, `rare`, `can_remove`) VALUES ('cctv1', 'CCTV 1', 1, 0, 1);
INSERT INTO `items` (`name`, `label`, `weight`, `rare`, `can_remove`) VALUES ('cctv2', 'CCTV 2', 1, 0, 1);
INSERT INTO `items` (`name`, `label`, `weight`, `rare`, `can_remove`) VALUES ('cctv3', 'CCTV 3', 1, 0, 1);
```

{% endcode %}
{% endtab %}

{% tab title="Add items on QBCore" %}
{% code title="Add these lines to \[qb-core/shared/items.lua]." lineNumbers="true" %}

```lua
['cctv1'] 				 = {['name'] = 'cctv1', 			  	  	['label'] = 'CCTV 1', 			['weight'] = 500, 		['type'] = 'item', 		['image'] = 'cctv1.png', 			['unique'] = false, 	['useable'] = true, 	['shouldClose'] = true,	['combinable'] = nil,   ['description'] = 'Placeable 360° CCTV camera'},
['cctv2'] 				 = {['name'] = 'cctv2', 			  	  	['label'] = 'CCTV 2', 			['weight'] = 500, 		['type'] = 'item', 		['image'] = 'cctv2.png', 			['unique'] = false, 	['useable'] = true, 	['shouldClose'] = true,	['combinable'] = nil,   ['description'] = 'Placeable 180° CCTV camera'},
['cctv3'] 				 = {['name'] = 'cctv3', 			  	  	['label'] = 'CCTV 3', 			['weight'] = 500, 		['type'] = 'item', 		['image'] = 'cctv2.png', 			['unique'] = false, 	['useable'] = true, 	['shouldClose'] = true,	['combinable'] = nil,   ['description'] = 'Placeable fixed camera'},
```

{% endcode %}
{% endtab %}
{% endtabs %}

##

## COMMON ISSUES

Please check out our [**Troubleshooting Guide**](https://docs.codesign.pro/coding-information/self-debugging#troubleshooting) before contacting our support.

🔔 <mark style="color:red;">**Folder Name**</mark> Make sure the name of the folder either `cd_cctv`.

🔔 <mark style="color:red;">**Encrypted Files**</mark> Do not edit the encrypted files in any way.

## ERROR CODES

If you see an error code not listed below, please open a script support ticket in the [Codesign Discord](https://discord.gg/codesign).

{% tabs %}
{% tab title="Server" %} <mark style="color:red;">**0001**</mark> - The simple answer is that you did not complete [#Step 2](#step-2-move-the-json-file) of the installation guide above.
{% endtab %}

{% tab title="Client" %}
N/A
{% endtab %}
{% endtabs %}

## 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_cctv` 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.

{% hint style="danger" %}
**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 overwrite your saved database.
{% endhint %}

{% hint style="warning" %}
**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.
{% endhint %}

{% tabs %}
{% tab title="v1.0.0" %}

### 30/01/2023

**Files Changed**:&#x20;

* [x] All Files
* [ ] All Files Except config.lua
* [ ] Specific Files

**Update Type**:

* [x] Mandatory
* [ ] Optional

**Changelog:**

{% hint style="success" %}
&#x20;**STATUS**

* **Development Stage:** COMPLETE
* **Alpha Test Stage:** COMPLETE
* **Beta Test Stage:** IN-PROGRESS
  {% endhint %}
  {% endtab %}

{% tab title="v1.0.3" %}

### 22/03/2023

**Files Changed**:&#x20;

* [x] All Files
* [ ] All Files Except config.lua
* [ ] Specific Files

**Update Type**:

* [ ] Mandatory
* [x] Optional

**Changelog:**

{% hint style="success" %}
**Add**

Added Failsafe checks for detection notify if no job is present
{% endhint %}

{% hint style="warning" %}
**Fix**

* Fixed issues with AcePerms and Discord Perms breaking the ui for people
* Fixed ui not showing No Access permissions yet if you remove all the permissions
* Fixed Search not sticking after person views and stop viewing a camera
* Fixed ui bug for information bubbles
  {% endhint %}
  {% endtab %}

{% tab title="v1.0.6" %}

### 15/06/2023

**Files Changed**:&#x20;

* [ ] All Files
* [ ] All Files Except config.lua
* [x] Specific Files

```
fxmanifest.lua
client/client.lua
```

**Update Type**:

* [ ] Mandatory
* [x] Optional

**Changelog:**

{% hint style="warning" %}
**Fix**

* Fixed cctv not updating properly for admins if access updated.
  {% endhint %}
  {% endtab %}

{% tab title="v1.0.7" %}

### 25/06/2023

**Files Changed**:&#x20;

* [ ] All Files
* [ ] All Files Except config.lua
* [x] Specific Files

```lua
fxmanifest.lua
configs (FULL FOLDER)
```

**Update Type**:

* [ ] Mandatory
* [x] Optional

**Changelog:**

{% hint style="warning" %}
**Fix**

* Fixed issue with ESX item not removing while placing CCTV (optional only for ESX users who want to use it item based).
  {% endhint %}
  {% endtab %}

{% tab title="v1.0.8" %}

### 18/07/2023

**Files Changed**:&#x20;

* [ ] All Files
* [ ] All Files Except config.lua
* [x] Specific Files

```lua
fxmanifest.lua
configs/server_customise_me.lua
server/server.lua
client/functions.lua
```

**Update Type**:

* [ ] Mandatory
* [x] Optional

**Changelog:**

{% hint style="warning" %}
**Fix**

* Fixed sending alerts to people with access and jobs with access.
  {% endhint %}
  {% endtab %}

{% tab title="v1.0.9" %}

### 07/08/2023

**Files Changed**:&#x20;

* [ ] All Files
* [ ] All Files Except config.lua
* [x] Specific Files

```lua
fxmanifest.lua
configs/server_customise_me.lua
server/server.lua
client/client.lua
```

**Update Type**:

* [ ] Mandatory
* [x] Optional

**Changelog:**

{% hint style="warning" %}
**Fix**

* Fixed to check access before sending alerts for detection.
* Fixed alerts firing for data loading to everyone.
* Race condition checking for sending detection alerts.
* Fixed Doorlock typo in notify.
  {% endhint %}
  {% endtab %}

{% tab title="v1.0.10" %}

### 23/04/2024

**Files Changed**:&#x20;

* [ ] All Files
* [ ] All Files Except config.lua
* [x] Specific Files

```lua
fxmanifest.lua
client/client.lua
```

**Update Type**:

* [ ] Mandatory
* [x] Optional

**Changelog:**

{% hint style="warning" %}
**Fix**

* Hotfix to disable cameras sometimes bugging out
  {% endhint %}
  {% endtab %}

{% tab title="v1.0.11" %}

### 22/07/2024

**Files Changed**:&#x20;

* [ ] All Files
* [ ] All Files Except config.lua
* [x] Specific Files

```lua
fxmanifest.lua
config/server_customise_me.lua
server/server.lua
```

**Update Type**:

* [ ] Mandatory
* [x] Optional

**Changelog:**

{% hint style="success" %}
**Add**

* Cached player source and identifier for less stress on server
  {% endhint %}
  {% endtab %}

{% tab title="v1.0.12" %}

### 22/10/2024

**Files Changed**:&#x20;

* [ ] All Files
* [ ] All Files Except config.lua
* [x] Specific Files

```lua
fxmanifest.lua
server/server.lua
html (full folder)
```

**Update Type**:

* [ ] Mandatory
* [x] Optional

**Changelog:**

{% hint style="warning" %}
**Fix**

* Fixed error in server console when player drops without loading completely.
* Fixed pagination overflow.
  {% endhint %}
  {% endtab %}
  {% endtabs %}
