# API

You can find many data extraction and update methods here to adapt to your other scripts.

## Optimization solution for HUD's

You need to add your hud this event handlers

Client-side / Server-side

```lua
s4-breathalyser:onUpdate
```

It will give you two arguments, argument 1 is Alcohol and argument 2 is Narco data.

Example use

````
```lua
RegisterNetEvent('s4-breathalyser:onUpdate')
AddEventHandler('s4-breathalyser:onUpdate', function(Alcohol, Narco)
```
````

## Exports

Whether the menu is open

```lua
exports["s4-breathalyser"].IsMenuOpen()
```

Returns the alcohol value in float data

```lua
exports["s4-breathalyser"].GetAlcohol()
```

Returns the narco value in float data

```lua
exports["s4-breathalyser"].GetNarco()
```

Should be used to add alcohol data

```lua
exports["s4-breathalyser"].UpdateAlcohol(value)
```

Should be used to add narco data

```lua
exports["s4-breathalyser"].UpdateNarco(value)
```

It removes alcohol and narcos from the player.

```lua
exports["s4-breathalyser"].ClearPlayer()
```

Returns alcohol data as a percentage

```lua
exports["s4-breathalyser"].GetAlcoholPercentage()
```

Returns narco data as a percentage

```lua
exports["s4-breathalyser"].GetNarcoPercentage()
```


---

# 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://docs.0resmon.org/0resmon/s4-resources/breathalyser/api.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.
