# Functions

## <mark style="color:green;">Camera</mark>

The Camera can only be invoked on the Client-Side!

{% tabs %}
{% tab title="Creating Camera" %}

```lua
exports["is_dialogv2"]:createCamera(entity, data)
```

* entity: `entity(ped)`
* data(optional): `object`
  * camera(optional): `object`
    * position(optional): `object`
      * x: `float`
      * y: `float`
      * z: `float`
    * offset(optional): `object`
      * x: `float`
      * y: `float`
      * z: `float`
    * fov(optional): `float`
    * ease(optional): `boolean`
    * easeTime(optional): `number`
  * animation(optional): `object`
    * dict: `string`
    * anim: `string`

**Example Usage**

```lua
-- Example 1

exports["is_dialogv2"]:createCamera(entity)

-- Example 2

exports["is_dialogv2"]:createCamera(entity, {
    camera = {
        position = {
            x = 0.0,
            y = 0.8,
            z = 0.7,
        },
        offset = {
            x = 0.0,
            y = 0.0,
            z = 0.5,
        },
        fov = 65.0,
        ease = true,
        easeTime = 1000,
    },
    animation = {
        dict = "missfbi3_party_d",
        anim = "stand_talk_loop_a_male1",
    },
})
```

{% endtab %}

{% tab title="Destroying Camera" %}

```lua
exports["is_dialogv2"]:destroyCamera(data)
```

* data(optional): `object`
  * ease(optional): `boolean`
  * easeTime(optional): `number`

**Example Usage**

```lua
-- Example 1

exports["is_dialogv2"]:destroyCamera()

-- Example 2

exports["is_dialogv2"]:destroyCamera({
    ease = true,
    easeTime = 1000,
})
```

{% endtab %}

{% tab title="Getting Camera State" %}

```lua
exports["is_dialogv2"]:isCameraActive()
```

return: `boolean`

**Example Usage**

```lua
local cameraState = exports["is_dialogv2"]:isCameraActive()

if cameraState then
    print("camera is active")
else
    print("camera is not active")
end    
```

{% endtab %}
{% endtabs %}

## <mark style="color:green;">Dialog</mark>

The Dialog can only be invoked on the Client-Side!

{% tabs %}
{% tab title="Creating Dialog" %}

```lua
exports["is_dialogv2"]:showDialog(data)
```

* data: `object`
  * typeEffect(optional): `boolean`
  * typeEffectSpeed(optional): `number`
  * allowSkip(optional): `boolean`
  * title: string
  * message: string
  * chat(optional): `object`
    * range(optional): `float`
    * message(optional): `boolean`
    * answer(optional): `boolean`
  * audio(optional): `object`
    * path: `string`
    * volume(optional): `number(0-100)`
  * tags(optional): `array`
    * text: `string`
    * color: `string(hex)`
    * icon(optional): `string`
  * buttons(optional): `array`
    * type(optional): `string("button", "item", "number", "text")`
    * text: `string`
    * onSelect: `function(...)`
    * canInteract: `function()`
  * items(optional): array
    * name: `string(item)`
    * path: `string(image)`

**Example Usage**

```lua
-- Example 1

exports["is_dialogv2"]:showDialog({
    title = "Example Title",
    message = "Example Message",
    buttons = {
        {text = "Example Button 1", onSelect = function(buttonIndex)
            exports["is_dialogv2"]:hideDialog()
            print(("Button: %s"):format(buttonIndex))
        end},
        {type = "button", text = "Example Button 2", onSelect = function(buttonIndex)
            exports["is_dialogv2"]:hideDialog()
            print(("Button: %s"):format(buttonIndex))
        end},
        {type = "number", text = "Your number...", onSelect = function(buttonIndex, value)
            exports["is_dialogv2"]:hideDialog()
            print(("Input: %s"):format(value))
        end},
        {type = "text", text = "Your text...", onSelect = function(buttonIndex, value)
            exports["is_dialogv2"]:hideDialog()
            print(("Input: %s"):format(value))
        end},
    },
})

-- Example 2

exports["is_dialogv2"]:showDialog({
    typeEffect = true,
    typeEffectSpeed = 15,
    allowSkip = false,
    title = "Example Title",
    message = "Example Message",
    tags = {
        {text = "TAG1", color = "#009BFF"},
        {text = "TAG2", color = "#FF425D", icon = "fa-solid fa-house"},
    },
    buttons = {
        {text = "Example Button 1", onSelect = function(buttonIndex)
            exports["is_dialogv2"]:hideDialog()
            print(("Button: %s"):format(buttonIndex))
        end, canInteract = function()
            return true
        end},
        {type = "button", text = "Example Button 2", onSelect = function(buttonIndex)
            exports["is_dialogv2"]:hideDialog()
            print(("Button: %s"):format(buttonIndex))
        end, canInteract = function()
            return false
        end},
        {type = "number", text = "Your number...", onSelect = function(buttonIndex, value)
            exports["is_dialogv2"]:hideDialog()
            print(("Input: %s"):format(value))
        end},
        {type = "text", text = "Your text...", onSelect = function(buttonIndex, value)
            exports["is_dialogv2"]:hideDialog()
            print(("Input: %s"):format(value))
        end},
        {type = "item", text = "Choosed Item", onSelect = function(buttonIndex, item)
            exports["is_dialogv2"]:hideDialog()
            print(("Name: %s, Path: %s, Count: %s, Label: %s"):format(item.name, item.path, item.count, item.label))
        end},
    },
    items = {
        {name = "meth", path = "nui://qb-inventory/html/images/meth_baggy.png"},
        {name = "weed_whitewidow", path = "https://as2.ftcdn.net/v2/jpg/02/16/71/15/1000_F_216711557_4b4flusrgydnwFabeeQMLlZo2Lr85Jw0.jpg"},
        {name = "weed_skunk", path = "images/weed_baggy.png"},
    },
})

-- Example 3

exports["is_dialogv2"]:showDialog({
    typeEffect = true,
    typeEffectSpeed = 15,
    allowSkip = false,
    title = "Example Title",
    message = "Example Message",
    chat = {
        range = 5.0,
        message = true,
        answer = true,
    },
    audio = {
        path = "audio/2pac.mp3",
        volume = 75,
    },
    tags = {
        {text = "TAG1", color = "#009BFF"},
        {text = "TAG2", color = "#FF425D", icon = "fa-solid fa-house"},
    },
    buttons = {
        {text = "Example Button 1", onSelect = function(buttonIndex)
            exports["is_dialogv2"]:hideDialog()
            print(("Button: %s"):format(buttonIndex))
        end, canInteract = function()
            return true
        end},
        {type = "button", text = "Example Button 2", onSelect = function(buttonIndex)
            exports["is_dialogv2"]:hideDialog()
            print(("Button: %s"):format(buttonIndex))
        end, canInteract = function()
            return false
        end},
        {type = "number", text = "Your number...", onSelect = function(buttonIndex, value)
            exports["is_dialogv2"]:hideDialog()
            print(("Input: %s"):format(value))
        end},
        {type = "text", text = "Your text...", onSelect = function(buttonIndex, value)
            exports["is_dialogv2"]:hideDialog()
            print(("Input: %s"):format(value))
        end},
        {type = "item", text = "Choosed Item", onSelect = function(buttonIndex, item)
            exports["is_dialogv2"]:hideDialog()
            print(("Name: %s, Path: %s, Count: %s, Label: %s"):format(item.name, item.path, item.count, item.label))
        end},
    },
    items = {
        {name = "meth", path = "nui://qb-inventory/html/images/meth_baggy.png"},
        {name = "weed_whitewidow", path = "https://as2.ftcdn.net/v2/jpg/02/16/71/15/1000_F_216711557_4b4flusrgydnwFabeeQMLlZo2Lr85Jw0.jpg"},
        {name = "weed_skunk", path = "images/weed_baggy.png"},
    },
})
```

{% endtab %}

{% tab title="Destroying Dialog" %}

```lua
exports["is_dialogv2"]:hideDialog()
```

**Example Usage**

```lua
exports["is_dialogv2"]:hideDialog()
```

{% endtab %}

{% tab title="Getting Dialog State" %}

```lua
exports["is_dialogv2"]:isDialogActive()
```

return: `boolean`

**Example Usage**

```lua
local dialogState = exports["is_dialogv2"]:isDialogActive()

if dialogState then
    print("dialog is active")
else
    print("dialog is not active")
end
```

{% endtab %}
{% endtabs %}

## <mark style="color:green;">Camera & Dialog Usage</mark>

```lua
-- Example 1

exports["is_dialogv2"]:createCamera(entity)
exports["is_dialogv2"]:showDialog({
    title = "Example Title",
    message = "Example Message",
    buttons = {
        {text = "Example Button 1", onSelect = function(buttonIndex)
            exports["is_dialogv2"]:hideDialog()
            print(("Button: %s"):format(buttonIndex))
        end},
        {type = "button", text = "Example Button 2", onSelect = function(buttonIndex)
            exports["is_dialogv2"]:hideDialog()
            print(("Button: %s"):format(buttonIndex))
        end},
        {type = "number", text = "Your number...", onSelect = function(buttonIndex, value)
            exports["is_dialogv2"]:hideDialog()
            print(("Input: %s"):format(value))
        end},
        {type = "text", text = "Your text...", onSelect = function(buttonIndex, value)
            exports["is_dialogv2"]:hideDialog()
            print(("Input: %s"):format(value))
        end},
    },
})
exports["is_dialogv2"]:destroyCamera()

-- Example 2

exports["is_dialogv2"]:createCamera(entity, {
    camera = {
        position = {
            x = 0.0,
            y = 0.8,
            z = 0.7,
        },
        offset = {
            x = 0.0,
            y = 0.0,
            z = 0.5,
        },
        fov = 65.0,
        ease = true,
        easeTime = 1000,
    },
    animation = {
        dict = "missfbi3_party_d",
        anim = "stand_talk_loop_a_male1",
    },
})
exports["is_dialogv2"]:showDialog({
    typeEffect = true,
    typeEffectSpeed = 15,
    allowSkip = false,
    title = "Example Title",
    message = "Example Message",
    chat = {
        range = 5.0,
        message = true,
        answer = true,
    },
    audio = {
        path = "audio/2pac.mp3",
        volume = 75,
    },
    tags = {
        {text = "TAG1", color = "#009BFF"},
        {text = "TAG2", color = "#FF425D", icon = "fa-solid fa-house"},
    },
    buttons = {
        {text = "Example Button 1", onSelect = function(buttonIndex)
            exports["is_dialogv2"]:hideDialog()
            print(("Button: %s"):format(buttonIndex))
        end},
        {type = "button", text = "Example Button 2", onSelect = function(buttonIndex)
            exports["is_dialogv2"]:hideDialog()
            print(("Button: %s"):format(buttonIndex))
        end},
        {type = "number", text = "Your number...", onSelect = function(buttonIndex, value)
            exports["is_dialogv2"]:hideDialog()
            print(("Input: %s"):format(value))
        end},
        {type = "text", text = "Your text...", onSelect = function(buttonIndex, value)
            exports["is_dialogv2"]:hideDialog()
            print(("Input: %s"):format(value))
        end},
        {type = "item", text = "Choosed Item", onSelect = function(buttonIndex, item)
            exports["is_dialogv2"]:hideDialog()
            print(("Name: %s, Path: %s, Count: %s, Label: %s"):format(item.name, item.path, item.count, item.label))
        end},
    },
    items = {
        {name = "meth", path = "nui://qb-inventory/html/images/meth_baggy.png"},
        {name = "weed_whitewidow", path = "https://as2.ftcdn.net/v2/jpg/02/16/71/15/1000_F_216711557_4b4flusrgydnwFabeeQMLlZo2Lr85Jw0.jpg"},
        {name = "weed_skunk", path = "images/weed_baggy.png"},
    },
})
exports["is_dialogv2"]:destroyCamera({
    ease = true,
    easeTime = 1000,
})
```


---

# 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://inside-scripts.gitbook.io/documentation/paid-scripts/dialog-v2/functions.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.
