# 🚬 pn-smoking

## Installation

### ox\_inventory

To install this script while having [ox\_inventory](https://github.com/CommunityOx/ox_inventory) you have to add this code to your **`items.lua`** file.

```lua
    ["cigarette"] = {
        label = "Cigarette",
        server = {
            export = "pn-smoking.startSmoking"
        }
    },
    ['joint'] = {
        label = 'Joint',
        server = {
            export = "pn-smoking.startSmoking"
        }
    },
    ["lighter"] = {
        label = "Lighter",
        server = {
            export = "pn-smoking.startSmoking"
        },
        consume = 1
    }
```

### Other inventories

If you use any other inventory that works with your framework, first of all you have to set `Config.OxInventory` in the `config.lua` file to `false` like this:

```lua
Config.OxInventory = false
```

Then, based on your framework you have to add these lines of code to `server/editable.lua` file:

#### ESX

```lua
ESX.RegisterUsableItem('cigarette', function(playerId)
    local xPlayer = ESX.GetPlayerFromId(playerId)
    xPlayer.removeInventoryItem('cigarette', 1)
    exports["pn-smoking"]:startSmoking(playerId, 'cigarette')
end)

ESX.RegisterUsableItem('joint', function(playerId)
    local xPlayer = ESX.GetPlayerFromId(playerId)
    xPlayer.removeInventoryItem('joint', 1)
    exports["pn-smoking"]:startSmoking(playerId, 'joint')
end)
```

#### QBCore

```lua
local QBCore = exports['qb-core']:GetCoreObject()

QBCore.Functions.CreateUseableItem('cigarette', function(source)
    local Player = QBCore.Functions.GetPlayer(source)
    if Player.Functions.RemoveItem('cigarette', 1) then
        exports["pn-smoking"]:startSmoking(playerId, 'cigarette')
    end
end)

QBCore.Functions.CreateUseableItem('joint', function(source)
    local Player = QBCore.Functions.GetPlayer(source)
    if Player.Functions.RemoveItem('joint', 1) then
        exports["pn-smoking"]:startSmoking(playerId, 'joint')
    end
end)
```


---

# 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://pineappleassets.gitbook.io/pineapple-assets/pn-smoking.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.
