> For the complete documentation index, see [llms.txt](https://nayzeee-dev.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nayzeee-dev.gitbook.io/docs/nayzeee-scripts/nayzeee-drug-selling/exports.md).

# Exports

***

### Server Exports

<details>

<summary>GetPlayerRank</summary>

Gets a player's trap rank/level.

```lua
local rank = exports['nayzeee-drugselling']:GetPlayerRank(source)
```

**Parameters:**

| Parameter | Type   | Description      |
| --------- | ------ | ---------------- |
| `source`  | number | Player server ID |

**Returns:**

```lua
{
    level = number,
    xp = number,
    title = string
}
```

</details>

<details>

<summary>AddPlayerXP</summary>

Adds XP to a player's trap rank.

```lua
exports['nayzeee-drugselling']:AddPlayerXP(source, amount)
```

**Parameters:**

| Parameter | Type   | Description      |
| --------- | ------ | ---------------- |
| `source`  | number | Player server ID |
| `amount`  | number | XP to add        |

</details>

<details>

<summary>ResetPlayerRank</summary>

Resets a player's trap rank.

```lua
exports['nayzeee-drugselling']:ResetPlayerRank(source)
```

</details>

<details>

<summary>GetDrugPrice</summary>

Gets the current price for a drug type.

```lua
local price = exports['nayzeee-drugselling']:GetDrugPrice(drugType, zone)
```

**Parameters:**

| Parameter  | Type   | Description          |
| ---------- | ------ | -------------------- |
| `drugType` | string | Drug type name       |
| `zone`     | string | (Optional) Zone name |

**Returns:** `number` - Price per unit

</details>

***

### Integration Examples

#### Custom Drug Source

```lua
-- Add XP when player produces drugs
RegisterNetEvent('druglab:productionComplete')
AddEventHandler('druglab:productionComplete', function(drugType, amount)
    local src = source
    local xp = amount * 5 -- 5 XP per unit produced
    exports['nayzeee-drugselling']:AddPlayerXP(src, xp)
end)
```

#### Rank-Based Restrictions

```lua
-- Require certain rank to access location
RegisterNetEvent('location:enter')
AddEventHandler('location:enter', function()
    local src = source
    local rank = exports['nayzeee-drugselling']:GetPlayerRank(src)
    
    if rank.level < 5 then
        TriggerClientEvent('ox_lib:notify', src, {
            description = 'You need Trap Rank 5 to enter here',
            type = 'error'
        })
        return false
    end
    
    -- Allow entry
    return true
end)
```

#### Price Display

```lua
-- Show drug prices in UI
local function GetAllPrices()
    local drugs = {'weed', 'coke', 'meth'}
    local prices = {}
    
    for _, drug in ipairs(drugs) do
        prices[drug] = exports['nayzeee-drugselling']:GetDrugPrice(drug)
    end
    
    return prices
end
```

#### Admin Reset Command

```lua
-- Admin command to reset player rank
RegisterCommand('resetrank', function(source, args)
    if not IsPlayerAdmin(source) then return end
    
    local target = tonumber(args[1])
    if target then
        exports['nayzeee-drugselling']:ResetPlayerRank(target)
        TriggerClientEvent('ox_lib:notify', source, {
            description = 'Reset trap rank for player ' .. target,
            type = 'success'
        })
    end
end, true)
```
