> For the complete documentation index, see [llms.txt](https://codestudio5m.gitbook.io/codestudio/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codestudio5m.gitbook.io/codestudio/our-scripts/multi-job-system/setup.md).

# Setup

## Setting Up the Script

* This Script Works Only in <mark style="color:yellow;">ESX and QB</mark>&#x20;
* The script includes an automatic SQL installer, but manual installation is also possible by turning off <mark style="color:yellow;">CodeStudio.AutoSQL</mark> in the config and installing the SQL query<br>

  <pre class="language-lua" data-title="By Default No Need"><code class="lang-lua">CREATE TABLE IF NOT EXISTS `player_multijob` (
      `id` INT(255) NOT NULL AUTO_INCREMENT,
      `identifier` VARCHAR(100) NOT NULL COLLATE 'utf8mb4_general_ci',
      `job` VARCHAR(100) NOT NULL COLLATE 'utf8mb4_general_ci',
      `grade` INT(11) NOT NULL,
      `removeable` TINYINT(1) NOT NULL,
      PRIMARY KEY (`id`) USING BTREE
  )
  COLLATE='utf8mb4_general_ci'
  ENGINE=InnoDB
  AUTO_INCREMENT=35
  ;

  </code></pre>
* UI can be accessed via command, key, or by selecting ped by target<br>

  <figure><img src="/files/lQ982c6ClmlMjTaz88RX" alt=""><figcaption></figcaption></figure>
* The script has admin commands for job assignment/removal from the player<br>

  <figure><img src="/files/uO55KrIeR8zxEepejGWN" alt=""><figcaption></figcaption></figure>
* You can set the maximum number of jobs that a player can save using <mark style="color:yellow;">CodeStudio.MaxJobs</mark>
* Auto job saving can be enabled with <mark style="color:yellow;">CodeStudio.AllowAutoJobSaving</mark> for automatic registration of jobs in the multi-job menu when the player receives a job
* If you are using QB, you can enable the on/off duty feature using <mark style="color:yellow;">CodeStudio.EnableDuty</mark>
* You can add non-removable default jobs to the multi-job menu that players cannot delete\ <img src="/files/KLDelOPdBG0qZnpepM6Y" alt="" data-size="original">\ <mark style="background-color:blue;">**This is a template example of how to add default jobs**</mark>

## Events and Exports

### Client Side

{% code title="Open Multi Job Menu" %}

```lua
TriggerEvent('cs:multijob:openUI', true)
```

{% endcode %}

{% code title="Close Multi Job Menu" %}

```lua
TriggerEvent('cs:multijob:openUI', false)
```

{% endcode %}

### Server Side

* Event to Remove Job from Multi Job Menu\
  \ <mark style="color:green;">\[</mark> <mark style="color:green;"></mark><mark style="color:green;">**identifier = player citizenid if QB and steam if ESX, job = job to be removed ]**</mark>

  <pre class="language-lua" data-full-width="false"><code class="lang-lua">TriggerEvent('cs:multijob:removeJob', identifier, job)

  </code></pre>
* Event to AddJob to Multi Job Menu<br>

  <mark style="color:green;">\[</mark> <mark style="color:green;"></mark><mark style="color:green;">**identifier = player citizenid if QB and steam if ESX, job = job to be removed, grade = job grade or rank ]**</mark>

  ```lua
  TriggerEvent('cs:multijob:addjob', identifier, job, grade)
  ```
* Event to Update Job Rank in Multi Job Menu<br>

  <mark style="color:green;">\[</mark> <mark style="color:green;"></mark><mark style="color:green;">**identifier = player citizenid if QB and steam if ESX, job = job to be removed, grade = job grade or rank ]**</mark>

  <pre class="language-lua"><code class="lang-lua"><strong>TriggerEvent('cs:multijob:updateJob', identifier, job, grade)
  </strong></code></pre>
* Event to Automatically Check a Player's Job and Add or Update It Automatically<br>

  ```lua
  TriggerEvent('cs:multijob:checkForJob')
  ```
