> For the complete documentation index, see [llms.txt](https://docs.menanak47.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.menanak47.com/multi-framework/ak47_drugmanagerv3/validate/client.md).

# Client

Synchronous client-side decision functions located in \`custom/client/validate.lua\`.   Return \`true\` to allow the action or \`false\` to block it.

#### `CanSellNPC`

Validates before a player starts or initiates selling to an NPC.

**Signature**

```lua
CanSellNPC(zoneData) -> boolean
```

**Data Structure (`zoneData`)**

```lua
{
    uid = "zone_1", -- string or "anywhere"
    setting = {
        name = "Downtown",
        currency = "cash",
        coprequired = 1,
        robchance = 10,
        rejectchance = 15
    }
}
```

**Example**

```lua
CanSellNPC = function(zoneData)
    if IsPedInAnyVehicle(PlayerPedId(), false) then
        Lib47.Notify('You cannot sell drugs from inside a vehicle!', 'error')
        return false
    end
    return true
end
```

***

#### `CanSellDealer`

Validates before a player opens a dealer menu or sells items to a dealer.

**Signature**

```lua
CanSellDealer(shopData) -> boolean
```

**Data Structure (`shopData`)**

```lua
{
    uid = "dealer_1",
    name = "Downtown Plug",
    shoptype = "dealer",
    defaultcurrency = "cash",
    items = {
        ["coke_pouch"] = { name = "coke_pouch", label = "Coke Pouch", sellprice = 300, buyprice = 500 }
    }
}
```

**Example**

```lua
CanSellDealer = function(shopData)
    return true
end
```

***

#### `CanBuyDealer`

Validates before a player purchases items from a dealer.

**Signature**

```lua
CanBuyDealer(shopData, item, amount) -> boolean
```

**Example**

```lua
CanBuyDealer = function(shopData, item, amount)
    return true
end
```

***

#### `CanAccessCornerboy`

Validates before a player opens a cornerboy ped interaction menu.

**Signature**

```lua
CanAccessCornerboy(cornerboyData) -> boolean
```

**Data Structure (`cornerboyData`)**

```lua
{
    uid = "corner_1",
    position = vector3(x, y, z),
    setting = {
        name = "Grove Corner",
        maxstock = 100,
        sellinterval = 5,
        profitrate = 10,
        currency = "cash"
    }
}
```

**Example**

```lua
CanAccessCornerboy = function(cornerboyData)
    return true
end
```

***

#### `CanStockCornerboy`

Validates before a player stocks drugs into a cornerboy.

**Signature**

```lua
CanStockCornerboy(cornerboyData, item, amount) -> boolean
```

***

#### `CanHarvestField`

Validates before a player begins harvesting a plant in a drug field.

**Signature**

```lua
CanHarvestField(fieldData, plantId) -> boolean
```

**Data Structure (`fieldData`)**

```lua
{
    uid = "field_weed",
    name = "Weed Field",
    item = { name = "coca_leaf", label = "Coca Leaf", minamount = 1, maxamount = 2 },
    radius = 15.0,
    delay = 3
}
```

**Example**

```lua
CanHarvestField = function(fieldData, plantId)
    if IsPedInAnyVehicle(PlayerPedId(), false) then
        return false
    end
    return true
end
```

***

#### `CanCollect`

Validates before a player collects from a collection zone.

**Signature**

```lua
CanCollect(collectData) -> boolean
```

**Data Structure (`collectData`)**

```lua
{
    uid = "collect_chem",
    setting = {
        item = { name = "chemicals", label = "Chemicals", amount = 1 },
        delay = 3,
        minigame = "none"
    }
}
```

***

#### `CanProcess`

Validates before a player starts processing in a lab zone.

**Signature**

```lua
CanProcess(processData) -> boolean
```

**Data Structure (`processData`)**

```lua
{
    uid = "lab_meth",
    setting = {
        item = { name = "meth_pouch", label = "Meth Pouch", amount = 1 },
        required = {
            ["chemicals"] = { name = "chemicals", label = "Chemicals", amount = 2 }
        },
        delay = 4,
        minigame = "mixing"
    }
}
```

***

#### `CanHandcraft`

Validates before a player starts handcrafting an item.

**Signature**

```lua
CanHandcraft(craftData) -> boolean
```

**Data Structure (`craftData`)**

```lua
{
    onuseitem = "coca_leaf",
    reward = { name = "coke_pouch", label = "Coke Pouch", amount = 1 },
    required = {
        ["bakingsoda"] = { name = "bakingsoda", label = "Baking Soda", amount = 1 }
    }
}
```

***

#### `CanUseDrug`

Validates before a player consumes a drug.

**Signature**

```lua
CanUseDrug(item, drugData) -> boolean
```

**Data Structure (`drugData`)**

```lua
{
    name = "coke_pouch",
    label = "Coke Pouch",
    usetype = "noseinhale",
    effectduration = 60,
    addhealth = 25,
    runspeed = 1.2
}
```

**Example**

```lua
CanUseDrug = function(item, drugData)
    if IsPedInAnyVehicle(PlayerPedId(), false) and drugData.usetype == 'bong' then
        Lib47.Notify('You cannot use a bong while driving!', 'error')
        return false
    end
    return true
end
```
