# Devtools

[**Download Here**](https://github.com/dsheedes/cd_devtools)

[**FiveM Forums Post**](https://forum.cfx.re/t/free-release-devtools-lua-json-table-viewer-by-codesign/3951738)

[**YouTube Showcase Video**](https://youtu.be/7iClw0DqVUU)

#### Translate

* [Click here to translate this page.](https://docs-codesign-pro.translate.goog/free-scripts/devtools?_x_tr_sl=en&_x_tr_tl=es&_x_tr_hl=en-GB&_x_tr_pto=nui)
* [How do I change language?](https://gyazo.com/38606313ac9a7c290dc2c72b6793bde6)

## INSTALLATION GUIDE

**1.** Unzip the `cd_devtools.zip` folder and place this folder in your server's resource folder.

**2.** Before starting the script, please read the `config.lua` (this is located inside the main cd\_devtools folder) and configure the script to suit your server's needs.

**3.** Add the resource to your server start config: `ensure cd_devtools`. The name of the folder must not be changed or the resource will not function correctly.

### Step 1 - Table Viewer

Simply trigger the event below, sending an LUA table in the first argument. The UI will only open when you trigger the event. This event can be placed in while loops and the displayed table will be updated.

**Notes**

* You can disable the NUI focus by clicking `middle mouse button` while the UI is still open, and the UI will stay on your screen even while you are triggering the event so you can see the table being updated live.
* You can reopen the UI and display the last table by pressing `numpad enter` while the UI is closed.
* Yes, it will be high ms on resmon when being triggered from a loop but this is a developer resource for dev servers only.

{% tabs %}
{% tab title="From server to client" %}

```lua
TriggerClientEvent('table', source, TABLE_HERE)
```

{% endtab %}

{% tab title="From client to client" %}

```lua
TriggerEvent('table', TABLE_HERE)
```

{% endtab %}
{% endtabs %}

### Step 2 - Quick Resource Restart

The purpose of this feature is to be able to quickly restart scripts when developing and debugging. To save a script to restart you can use the chat command below to save your chosen script.

Use the chat command `/restart_script "resource_name"`  to save the name of your chosen resource in the `restart_script.txt` file and cache it in the server side. Now when you start your server or restart the resource you can simply press the `(numpad +)` key to restart the resource.

### Chat commands

| **Command**      | **Example**                 | **Description**                                                                                                            |
| ---------------- | --------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| /restart\_script | /restart\_script cd\_garage | Save the name of a resource to use in the quick restart keypress. The example command will save the resource "cd\_garage". |

### Default Key Binds

| **Key**             | **Description**                                                             |
| ------------------- | --------------------------------------------------------------------------- |
| Middle Mouse Button | While the UI is opened, this will toggle the NUI focus *(mouse on screen).* |
| Escape              | Close the UI.                                                               |
| NUMPAD +            | Quickly restart your chosen script.                                         |
| Numpad Enter        | Reopen the UI and display the last table.                                   |

## SCRIPT NOT WORKING?

### Common Issues

🔔 **Folder Name** Make sure the name of the folder is `cd_devtools.`

### **Troubleshooting**

**1.** Check for obvious error prints in the server console and the client F8 console. If you don't see any obvious errors make sure to restart the script while the server is live and check again.

**2.** If none of the above worked, have a second read through the installation guide above, you may have missed something - you are only human.

*If all else fails, contact the Codesign Team in the* [*Codesign Discord*](https://discord.gg/codesign)*.*

## CONFIGS & LOCALES

{% tabs %}
{% tab title="Config" %}

```lua
Config = {}
Config.Keys={['ESC']=322,['F1']=288,['F2']=289,['F3']=170,['F5']=166,['F6']=167,['F7']=168,['F8']=169,['F9']=56,['F10']=57,['~']=243,['1']=157,['2']=158,['3']=160,['4']=164,['5']=165,['6']=159,['7']=161,['8']=162,['9']=163,['-']=84,['=']=83,['BACKSPACE']=177,['TAB']=37,['Q']=44,['W']=32,['E']=38,['R']=45,['T']=245,['Y']=246,['U']=303,['P']=199,['[']=39,[']']=40,['ENTER']=18,['CAPS']=137,['A']=34,['S']=8,['D']=9,['F']=23,['G']=47,['H']=74,['K']=311,['L']=182,['LEFTSHIFT']=21,['Z']=20,['X']=73,['C']=26,['V']=0,['B']=29,['N']=249,['M']=244,[',']=82,['.']=81,['LEFTCTRL']=36,['LEFTALT']=19,['SPACE']=22,['RIGHTCTRL']=70,['HOME']=213,['PAGEUP']=10,['PAGEDOWN']=11,['DELETE']=178,['LEFTARROW']=174,['RIGHTARROW']=175,['TOP']=27,['DOWNARROW']=173,['NENTER']=201,['N4']=108,['N5']=60,['N6']=107,['N+']=96,['N-']=97,['N7']=117,['N8']=61,['N9']=118,['UPARROW']=172,['INSERT']=121,['MMB']=27}

Config.Keys = {
    open_ui = Config.Keys['NENTER'], --(numpad enter)

    toggle_nuifocus = Config.Keys['MMB'], --(middle mouse button)

    restart_script = Config.Keys['N+'], --(numpad +)
}
```

{% 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 delete your old `cd_devtools` folder, download and add in the latest version, reconfigure the configs folder and restart your server.
* **Specific Files -** This means you can simply copy and paste the **SPECIFIC** new files over the old ones and restart the server.

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

### 11/07/2021

**Files Changed**:&#x20;

* [x] All files
* [ ] Specific Files

**Update Type**:

* [x] Mandatory
* [ ] Optional

**Changelog:**

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

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

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

### 14/07/2021

**Files Changed:**&#x20;

* [x] All files
* [ ] Specific Files

**Update Type:**

* [ ] Mandatory
* [x] Optional

**Changelog:**

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

* Added version check
  {% endhint %}

{% hint style="info" %}
**Edit**

* Minor code clean-up
* Enable NUI focus be default when opening the table viewer UI
* Shortened the event to open the table viewer UI for quality of life
  {% endhint %}

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

* Fix for the UI not opening after you closed it when the previous table is the same as the current one
  {% endhint %}
  {% endtab %}

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

### 19/12/2021

**Files Changed:**&#x20;

* [x] All files
* [ ] Specific Files

**Update Type:**

* [ ] Mandatory
* [x] Optional

**Changelog:**

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

* Added a small quality of life feature - the ability to reopen the UI and view the last table after it has been closed.
  {% endhint %}
  {% endtab %}
  {% endtabs %}
