> 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/server.md).

# Server

Use these exports only if you want another resource to read stable `rcore_drugs` upgrade data.

## ⬆️ Upgrade Exports

<details>

<summary>HasUpgrade</summary>

Checks whether a lab has a purchased upgrade.

```lua
---@param labId number
---@param upgradeKey string
---@return boolean
local hasUpgrade = exports.rcore_drugs:HasUpgrade(labId, upgradeKey)
```

</details>

<details>

<summary>GetPurchasedUpgrades</summary>

Returns purchased upgrade keys for a lab.

```lua
---@param labId number
---@return table
local upgrades = exports.rcore_drugs:GetPurchasedUpgrades(labId)
```

</details>

<details>

<summary>GetUpgradeConfig</summary>

Returns an upgrade config and its category key.

```lua
---@param upgradeKey string
---@return table|nil upgradeConfig
---@return string|nil categoryKey
local config, category = exports.rcore_drugs:GetUpgradeConfig(upgradeKey)
```

</details>

<details>

<summary>GetCategoryUpgrades</summary>

Returns all upgrades in a category.

```lua
---@param categoryKey string
---@return table
local upgrades = exports.rcore_drugs:GetCategoryUpgrades(categoryKey)
```

</details>

<details>

<summary>IsUpgradeAvailable</summary>

Checks whether an upgrade is available for a lab.

```lua
---@param labId number
---@param upgradeKey string
---@return boolean
local available = exports.rcore_drugs:IsUpgradeAvailable(labId, upgradeKey)
```

</details>

<details>

<summary>GetLabBonuses</summary>

Returns the total bonus value for one bonus type.

```lua
---@param labId number
---@param bonusType string
---@param drugType string|nil
---@return number
local bonus = exports.rcore_drugs:GetLabBonuses(labId, 'fasterTime', 'meth')
```

</details>

<details>

<summary>GetAllLabBonuses</summary>

Returns all known lab bonus totals.

```lua
---@param labId number
---@return table
local bonuses = exports.rcore_drugs:GetAllLabBonuses(labId)
```

Default keys:

```lua
{
    fasterTime = 0,
    moreItems = 0,
    fasterGrowth = 0,
    lessPolice = 0
}
```

</details>

## 📡 Net Events

<details>

<summary>onDealSuccess</summary>

Triggered when a player successfully completes a drug deal.

```lua
AddEventHandler('rcore_drugs:api:server:onDealSuccess', function(playerId, selectedDrugs, totalPrice)
    print('Player ' .. playerId .. ' completed a deal for $' .. totalPrice)
end)
```

Parameters:

| Name            | Type     | Description                                                  |
| --------------- | -------- | ------------------------------------------------------------ |
| `playerId`      | `number` | The server ID of the player                                  |
| `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>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://documentation.rcore.cz/paid-resources/rcore_drugs/api/server.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.
