> For the complete documentation index, see [llms.txt](https://documentation.rcore.cz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.rcore.cz/paid-resources/rcore_drugs/api/client.md).

# Client

Use these exports only if you want to integrate another resource with `rcore_drugs` client features.

## 🎮 Minigame Exports

<details>

<summary>StartMinigame</summary>

Starts a minigame and waits for the result.

```lua
---@param name string
---@return boolean success
local success = exports.rcore_drugs:StartMinigame(name)
```

Example:

```lua
local success = exports.rcore_drugs:StartMinigame('meth_reaction_tank')

if success then
    print('Minigame completed')
end
```

</details>

<details>

<summary>StartMinigameAsync</summary>

Starts a minigame and returns the result in a callback.

```lua
---@param name string
---@param callback fun(success: boolean)
exports.rcore_drugs:StartMinigameAsync(name, callback)
```

Example:

```lua
exports.rcore_drugs:StartMinigameAsync('weed_packaging', function(success)
    if success then
        print('Packaging completed')
    end
end)
```

</details>

<details>

<summary>IsMinigameActive</summary>

Checks if a minigame is currently active.

```lua
---@param name string
---@return boolean
local active = exports.rcore_drugs:IsMinigameActive(name)
```

</details>

<details>

<summary>CancelMinigame</summary>

Cancels an active minigame by name.

```lua
---@param name string
exports.rcore_drugs:CancelMinigame(name)
```

</details>

## 📡 Net Events

<details>

<summary>onDealSuccess</summary>

Triggered on the client when the player successfully completes a drug deal.

```lua
RegisterNetEvent('rcore_drugs:api:client:onDealSuccess', function(selectedDrugs, totalPrice)
    print('Deal completed for $' .. totalPrice)
end)
```

Parameters:

| Name            | Type     | Description                                                  |
| --------------- | -------- | ------------------------------------------------------------ |
| `selectedDrugs` | `table`  | Array of sold drugs, each entry contains `name` and `amount` |
| `totalPrice`    | `number` | Total price of the deal                                      |

`selectedDrugs` example:

```json
[{"amount": 1, "name": "joint"}]
```

</details>
