# User guide

## 1. Using the Text 3D

{% hint style="danger" %}
DO NOT trigger this function on every tick; it is meant to be activated as a toggle.
{% endhint %}

You can use the text 3D as showed in the example bellow:

```lua
exports['dynasty_text3d']:Text3D({
        id = "Default text 3D ID",
        coords = vec3(0, 0, 0),
        distance = 3,
        markerDistance = 10.0,
        marker = true,
        key = "E",
        message = "Default Text 3D message",
})
```

## 2. Default Text 3D

In case you use a notification and don't fill any of the parameters, it will be filled with the value stated in the Config.file. For example if the parameter `keyBoxColor`is not used, it will be filled with the value `0,255,192,130` in this case.

```lua
Config.DefaultText3D = {
    id = "Default text 3D ID",
    coords = vec3(0, 0, 0),
    distance = 1.5,
    markerDistance = 3.0,
    markerColor = { 0, 255, 192, 255 },
    marker = true,
    key = "E",
    keyBoxColor = { 0, 255, 192, 130 },
    keyTextColor = { 255, 255, 255, 255 },
    message = "Default Text 3D message",
    messageBoxColor = { 0, 255, 192, 130 },
    messageTextColor = { 255, 255, 255, 255 },
    enabled = true,
}
```

## 3. Text 3D configuration

### 3.1 ID

```lua
id = "Default text 3D ID"
```

In this case the ID you use to call this Text 3D is `Default text 3D ID`

### 3.2 Coords

```lua
coords = vec3(0, 0, 0)
```

In this case the coords the Text 3D will appear are `vec3(0, 0, 0)`

### 3.3 Distance

```lua
distance = 1.5
```

In this case the distance from where you can see the Text 3D is `1.5`

### 3.4 Marker distance

```lua
markerDistance = 3.0
```

In this case the distance from where you can see the marker is `3.0`

### 3.5 Marker color

```lua
markerColor = { 0, 255, 192, 255 }
```

In this case the color of the marker is `0, 255, 192, 255`

{% embed url="<https://htmlcolorcodes.com/>" %}
Example of where you can get colors
{% endembed %}

### 3.6 Marker enable

```lua
marker = true
```

In this case the marker enable is `true`

### 3.7 Key

```lua
key = "E"
```

In this case the key that appears is `E`

### 3.8 Key box color

```lua
keyBoxColor = { 0, 255, 192, 130 }
```

In this case the color of the key box is `0, 255, 192, 130`

### 3.9 Key text color

```lua
keyTextColor = { 255, 255, 255, 255 }
```

In this case the color of the key text is `0, 255, 192, 130`

### 3.10 Message

```lua
message = "Default Text 3D message"
```

In this case the message of the Text 3D is `Default Text 3D message`

### 3.11 Message box color

```lua
messageBoxColor = { 0, 255, 192, 130 }
```

In this case the message box color is `0, 255, 192, 130`

### 3.11 Message text color

```lua
messageTextColor = { 255, 255, 255, 255 }
```

In this case the message text color is `0, 255, 192, 130`

### 3.12 Text 3D enable

```lua
enabled = true
```

In this case the text 3D enable is `true`

## 4. Multiple Text 3D options

The example bellow shows how to use multiple options

```lua
exports['dynasty_text3d']:Text3D({
        id = "text-1",
        coords = vec3(0, 0, 0),
        distance = 3, -- distance to open the menu dialog
        markerDistance = 10.0, -- distance to show the marker
        marker = true, -- ACTIVATE THE MARKER ONLY FOR THE FIRST ELEMENT
        key = "E",
        message = "Buy equipment",
})
exports['dynasty_text3d']:Text3D({
        id = "text-2",
        coords = vec3(0, 0, 0),
        distance = 3, -- distance to open the menu dialog
        key = "F",
        message = "Sell equipment",
})
exports['dynasty_text3d']:Text3D({
        id = "text-3",
        coords = vec3(0, 0, 0),
        distance = 3, -- distance to open the menu dialog
        key = "G",
        message = "Deposit objects",
})
```

### 1. Text 3D position

Let's take the example above. If you have 3 options in the same position, you can also position them up or down depending on your need with the parameter `position`

```lua
exports['dynasty_text3d']:Text3D({       
        id = "text-2",
        coords = vec3(0, 0, 0),
        distance = 3, -- distance to open the menu dialog
        key = "F",
        message = "Sell equipment",
        position = { x = 0.0, y = 0.04 },
})
```

{% hint style="info" %}
Approximately every 0.04 is the recommended size to position each box. If you have 3 for example, you can put nothing in the first, in the second in 0.04 and the last in 0.08 and if you want to make it go up, you can do it like this `position = { x = 0.0, y = -0.04 }`
{% endhint %}

## 5. Add functionality to the Text 3D

### 5.1 Install Ox\_Lib

{% embed url="<https://github.com/overextended/ox_lib/releases>" %}
**ox\_lib** Official Repository
{% endembed %}

{% hint style="info" %}
**NOTE**: It is important that the **ox\_lib** script is started before starting our script.
{% endhint %}

### 5.2 Add ox\_lib to the script

Go to **fxmanifest.lua** file inside your script and add the code below

```lua
shared_scripts {
      '@ox_lib/init.lua'
  }
```

<figure><img src="https://2652661357-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUsY4h9tsm7XSZY5ZzV3l%2Fuploads%2FtGRqs2h0ZrEEP6y1Mrrf%2FCsssssa.PNG?alt=media&#x26;token=8d7bb612-2859-48d9-9120-dec53dcc477c" alt=""><figcaption><p>If you have done everything right, you should see something similar to this.</p></figcaption></figure>

### 5.2 Add ox\_lib to the script

Add **ox\_lib** pointer to your script as the example shown below

```lua
local mechanic1 = lib.points.new({
    coords = (0.0, 0.0, 0.0),  --- the coords of the place you want the interaction
    distance = 5,                         -- distance from the coord to work
    dunak = 'nerd',
})

local garage1Key = lib.addKeybind({
    name = 'mechanic',
    description = 'press E to open mechanic menu',
    defaultKey = 'E',
    onPressed = function(self)
        print("Here you put your function to open mechanic menu")
    end,
})

mechanic1Key:disable(true) -- disables the keybind

function garage1:onEnter()
    garage1Key:disable(false) -- enables the keybind
end

function garage1:onExit()
    garage1Key:disable(true) -- disables the keybind
end
```

{% hint style="info" %}
Here is an example for a mechanic job where you get to 5 meters near the`(0.0,0.0,0.0)` coords and press the "E" key and prints *"Here you put your function to open mechanic menu"*
{% endhint %}

## 6. Remove Text 3D

We use the ID of the Text 3D to remove it like the example below

```lua
exports['dynasty_text3d']:DeleteText3D('DefaultText')
```

In this example the Text 3D with the ID `DefaultText` is removed
