# 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>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://codestudio5m.gitbook.io/codestudio/our-scripts/drunk-system-+-alcohol-tester/setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
