# Exports & Events

{% hint style="info" %}

### Types & Classes

All types & classes can be found in shared/unlocked/types.lua.
{% endhint %}

{% hint style="info" %}

### Suggestions?

If you wish to have any exports and or events added, please head over to our [Discord](https://discord.zykeresources.com/) and create a suggestion post. We are happy to allow for easier integration within other resources.
{% endhint %}

## Client Sided Exports

### Get Item Data

> Returns all of the active item data in the cache. This will be empty if you don't have an item out at the time.\
> \
> **Example:**
>
> ```lua
> ---@return CigaretteData | CigaretteData | BongData | VapeData | nil
> exports["zyke_smoking"]:GetItemData()
> ```

### Transfer Item

> This export will find the closest player, and transfer the smokeable you currently have equipped to that player if it is within range.\
> \
> **Example:**
>
> ```lua
> exports["zyke_smoking"]:TransferItem()
> ```

### Switch Placement

> Switches placement of your smokeable, if possible. Toggles between your hand and mouth.\
> \
> **Example:**
>
> ```lua
> exports["zyke_smoking"]:SwitchItemPlacement()
> ```

### Is High

> Returns if you currently have any effect running from our resource.\
> \
> **Example:**
>
> ```lua
> ---@return boolean
> exports["zyke_smoking"]:IsHigh()
> ```

### Has Walk Effect

> Returns if you currently have any walking effect because of your high.\
> \
> **Example:**
>
> ```lua
> ---@return boolean
> exports["zyke_smoking"]:HasWalkEffect()
> ```

### Has Screen Effect

> Returns if you currently have any screen effect because of your high.\
> \
> **Example:**
>
> ```lua
> ---@return boolean
> exports["zyke_smoking"]:HasScreenEffect()
> ```

### Get Amount In Smokeable

> Returns the amount you have left for your smokeable.\
> \
> **Example:**
>
> ```lua
> ---@return number | 0
> exports["zyke_smoking"]:GetAmount()
> ```

### Get Battery In Vape

> Returns the battery level for your vape.\
> \
> **Example:**
>
> ```lua
> ---@return number | 0
> exports["zyke_smoking"]:GetAmount()
> ```

### Get Water In Bong

> Returns the water level for your bong.\
> \
> **Example:**
>
> ```lua
> ---@return number | 0
> exports["zyke_smoking"]:GetWater()
> ```

### Is Occupied

> Check if a player is currently occupied with any smokeable.\
> \
> **Example:**
>
> ```lua
> ---@return boolean
> exports["zyke_smoking"]:IsOccupied()
> ```

### Refill Bong Water

> Refill the bong water, you can tie this export with an inventory like ox\_inventory, and avoid having to use a separate water item since usability is already occupied.\
> \
> **Example:**
>
> ```lua
> exports["zyke_smoking"]:RefillBongWater()
> ```
>
> {% code title="ox\_inventory/data/items.lua" fullWidth="false" %}
>
> ```lua
> ["water"] = {
>     label = "Water",
>     weight = 200,
>     stack = true,
>     close = false,
>     buttons = {
>         {
>             label = "Refill Bong",
>             action = function()
>                 exports["zyke_smoking"]:RefillBongWater()
>             end
>         },
>     },
> },
> ```
>
> {% endcode %}

## Server Sided Exports

### Is Occupied

> Check if a player is currently occupied with any smokeable.\
> \
> **Example:**
>
> ```lua
> ---@param playerId integer
> ---@return boolean
> exports["zyke_smoking"]:IsOccupied(playerId)
> ```

## Client Sided Events

### Sync Item Data (Catch)

> Gives you a table of the latest item data for your current item.\
> \
> **Example:**
>
> ```lua
> ---@param itemData CigaretteData | CigaretteData | BongData | VapeData | nil
> RegisterNetEvent("zyke_smoking:SyncItemData", function(itemData)
>     -- Do something
> end)
> ```

### Stop Using Item (Catch)

> Triggered when you stop using an item.\
> \
> **Example:**
>
> ```lua
> RegisterNetEvent("zyke_smoking:StopUsingItem", function()
>     -- Do something
> end)
> ```

### Start Inhaling (Catch)

> Triggered when you start inhaling.\
> \
> **Example:**
>
> ```lua
> RegisterNetEvent("zyke_smoking:StartInhaling", function()
>     -- Do something
> end)
> ```

### Stop Inhaling (Catch)

> Triggered when you stop inhaling.\
> \
> **Example:**
>
> ```lua
> RegisterNetEvent("zyke_smoking:StopInhaling", function()
>     -- Do something
> end)
> ```

## Server Sided Events

### Transfer Item (Send)

> Additional to the client sided export, you can trigger the transfer item event directly and transfer your smokeable.\
> \
> **Example:**
>
> ```lua
> ---@param targetId integer @Server id
> TriggerServerEvent("zyke_smoking:TransferItem", targetId)
> ```
