# HRNPCDialogue

## Installation

* Download the dependency [HRLib](https://hrscripts.gitbook.io/hrscripts-documentation/resources/broken-reference)
* Download [HRNPCDialogue](https://github.com/HRScripts/HRNPCDialogue)
* Write this in your server.cfg:\
  `start HRLib`\
  `start HRNPCDialog`

## Preview

<figure><img src="https://1248811810-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXqbA5Sf27l8s5N2ZDHzg%2Fuploads%2FMj4bPHb52Gp63nTsSBFQ%2Fimage.png?alt=media&#x26;token=4daec5ab-dd25-4fb9-b4e9-70b5228d3392" alt=""><figcaption></figcaption></figure>

```lua
local config = {}

config.turnOff = { -- Choose the different options to turn off on focus
    minimap = true,
    playerVisibility = true
}

config.transitionDuration = 2500 -- In miliseconds
```

## External Connections

### Client Export

```lua
exports.HRNPCDialog:startDialogue(targetPed, options, createPed)
```

### Callback

```lua
HRLib.Callback('HRNPCDialog:startDialogue', targetPed, options, createPed) -- Client side
HRLib.ClientCallback('HRNPCDialog:startDialogue', targetPed, options, createdPed)
```

### Parameters

* targetPed: integer?
  * the ped, the camera must be focused on
* options: HRNPCDialgueOptions
  * dialgue settings/options
* createPed: { model: string|integer, animation: { dict: string, anim: string }?, coords: vector4 }?
  * feature that allows you to create a ped directly with this function

## Example

```lua
exports.HRNPCDialog:startDialogue(nil, {
    npcName = 'John Smith',
    questions = {
        {
            label = 'Is John Smith a real name?',
            possibleAnswers = {
                {
                    label = 'Yes, it is',
                    closeOnSelect = true,
                    onSelect = function()
                        print('Wrong Answer!')
                    end
                },
                {
                    label = 'No, it isn\'t',
                    closeOnSelect = true,
                    onSelect = function()
                        print('Correct answer!')
                    end
                }
            }
        }
    },
    onCancel = function()
        print('Don\'t you know the name John Smith?')
    end
}, {
    model = 'a_m_m_eastsa_02',
    animation = { dict = 'mini@strip_club@idles@bouncer@base', anim = 'base' },
    coords = vector4(1404.2367, -1565.6797, 56.4536, 91.8913)
})
```
