> 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/drunk-system-+-alcohol-tester/setup.md).

# Setup

## Setting Up the Script

1. The script is standalone in nature, and you can find the required information in the config itself
2. You can use BreathAnalyzer with commands or as an item:&#x20;
   * <pre class="language-lua" data-title="qb-core/shared/items.lua " data-overflow="wrap"><code class="lang-lua">["alcohol_tester"] = {
     	["name"] = "alcohol_tester",                                                        
     	["label"] = "Alcohol Tester",
     	["weight"] = 0,
     	["type"] = "item",
     	["image"] = "alcohol_tester.png",
     	["unique"] = false,
     	["useable"] = true,
     	["shouldClose"] = true,
     	["combinable"] = nil,
     	["description"] = ""
     },
     </code></pre>
   * <pre class="language-lua" data-title="ox_inventory/data/items.lua" data-overflow="wrap"><code class="lang-lua">['alcohol_tester'] = {
         label = 'Alcohol Tester',
         weight = 0,
         stack = true,
         close = true,
         description = ""
     },
     </code></pre>

## Events and Exports

### Client Sided

1. <pre class="language-lua" data-title="Open UI"><code class="lang-lua"><strong>TriggerEvent(cs:drunk:openUI)
   </strong></code></pre>
2. <pre class="language-lua" data-title="Close UI"><code class="lang-lua"><strong>TriggerEvent(cs:drunk:closeUI)
   </strong></code></pre>
3. Triggered Event when drunk level updates:

   ```lua
   RegisterNetEvent('cs:drunk:updateLevel', function(updatedLevel)
       print(updatedLevel)
   end)
   ```
4. <pre class="language-lua" data-title="Check If Player is Drunk"><code class="lang-lua">exports['cs_drunk']:isDrunk()
   </code></pre>
5. <pre class="language-lua" data-title="Get Player Drunk Value"><code class="lang-lua">exports['cs_drunk']:GetDrunkLevel()
   </code></pre>
6. <pre class="language-lua" data-title="Set Player Drunk Value"><code class="lang-lua">exports['cs_drunk']:SetDrunkLevel(value)
   </code></pre>
7. <pre class="language-lua" data-title="Add Player Drunk Value"><code class="lang-lua">exports['cs_drunk']:AddDrunkLevel(value)
   </code></pre>
8. <pre class="language-lua" data-title="Remove Player Drunk Value"><code class="lang-lua">exports['cs_drunk']:RemoveDrunkLevel(value)
   </code></pre>

### Server Sided

* <pre class="language-lua" data-title="Get Player Drunk Value"><code class="lang-lua">exports['cs_drunk']:GetDrunkLevel(Player_ID)
  </code></pre>
* <pre class="language-lua" data-title="Set Player Drunk Value"><code class="lang-lua">exports['cs_drunk']:SetDrunkLevel(Player_ID, value)
  </code></pre>
* <pre class="language-lua" data-title="Add Player Drunk Value"><code class="lang-lua">exports['cs_drunk']:AddDrunkLevel(Player_ID, value)
  </code></pre>
* <pre class="language-lua" data-title="Remove Player Drunk Value"><code class="lang-lua">exports['cs_drunk']:RemoveDrunkLevel(Player_ID, value)
  </code></pre>

## Example

Make your items show the drunk percentage in the drunk tester

### ESX&#x20;

Example of how you can increase the drunk percentage when using an item. You can implement the same logic to other items. I have shown you with the beer item under `esx_optionalneeds/server/main.lua`

<figure><img src="/files/qXQLPECysugKiXpCR6Zo" alt=""><figcaption><p>esx_optionalneeds</p></figcaption></figure>

### QBCore

Example of how you can increase the drunk percentage when using an item. You can implement the same logic for other items or events. I've demonstrated this with the alcohol use item under \
`qb-smallresources/client/consumables.lua`

<figure><img src="/files/B77IRFo82Zwrek0OIJbI" alt=""><figcaption><p>qb-smallresources</p></figcaption></figure>

### OX Inventory&#x20;

Example of how you can increase the drunk percentage when using an item. You can implement the same logic for other items or events. I've demonstrated this with the beer item under \
`ox_inventory\data\items.lua`&#x20;

<figure><img src="/files/En1Hqq4LwL8lcE5gpUxR" alt=""><figcaption><p>ox_inventory</p></figcaption></figure>
