> For the complete documentation index, see [llms.txt](https://atiysus-organization.gitbook.io/aty-scripts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://atiysus-organization.gitbook.io/aty-scripts/ui-kit/usage/loading-bar.md).

# Loading Bar

## Loading Bar Usage Guide

### **Creating a** Loading Bar

To create a loading bar, use the following function:

```lua
aty.loading("Purchasing", 7000, {
    dict = "mini@sprunk",
    anim = "plyr_buy_drink_pt1",
    flags = 1,
    duration = 7000,
    prop = "p_amb_coffeecup_01",
    bone = 28422,
    offset = vector3(0.0, 0.0, 0.0),
    rot = vector3(0.0, 0.0, 0.0),
    disableControls = false,
    cancel = true,
}, function(success)
    if success == "ok" then -- Here will be the used when the loading is done.
        aty.sendNotify("Purchased", "You have purchased a drink.", "success", 8000)
    elseif success == "cancelled" then -- Here will be the used when the loading is canceled.
        aty.sendNotify("Purchased", "You have canceled the puchasing.", "error", 8000)
    else -- Here will be the used when the loading is failed or already active.
        aty.sendNotify("Purchased", "You can't do this now!", "error", 8000)
    end
end)
```

***

## **Loading Bar Parameters**

### **Title**

* `"Purchasing"`\
  The title of the loading bar, displayed as a notification.\
  **Type**: `string`

### **Duration**

* `7000`\
  The duration (in milliseconds) for the loading bar to complete.\
  **Type**: `integer`

### **Animation Dictionary (`dict`)**

* `"mini@sprunk"`\
  The animation dictionary to be used during the loading sequence.\
  **Type**: `string`

### **Animation Name (`anim`)**

* `"plyr_buy_drink_pt1"`\
  The specific animation to play from the animation dictionary.\
  **Type**: `string`

### **Flags**

* `1`\
  Animation behavior flags, controlling playback settings.\
  **Type**: `integer`

### **Prop**

* `"p_amb_coffeecup_01"`\
  The name of the prop (object) to attach to the character during the animation.\
  **Type**: `string`

### **Bone**

* `28422`\
  The bone index to which the prop is attached.\
  **Type**: `integer`

### **Offset**

* `vector3(0.0, 0.0, 0.0)`\
  The position offset for the prop relative to the specified bone.\
  **Type**: `vector3`

### **Rotation (`rot`)**

* `vector3(0.0, 0.0, 0.0)`\
  The rotation offset for the prop relative to the specified bone.\
  **Type**: `vector3`

### **Disable Controls**

* `false`\
  Specifies whether player controls should be disabled during the loading bar sequence.\
  **Type**: `boolean`

### **Cancel**

* `true`\
  Determines whether the player can cancel the loading bar.\
  **Type**: `boolean`

***

## **Callback Function**

The callback function handles the outcome of the loading bar:

* **`"ok"`**: Triggered when the loading bar completes successfully.

  ```lua
  aty.sendNotify("Purchased", "You have purchased a drink.", "success", 8000)
  ```
* **`"cancelled"`**: Triggered when the loading bar is canceled.

  ```lua
  aty.sendNotify("Purchased", "You have canceled the purchasing.", "error", 8000)
  ```
* **Other**: Triggered when the loading bar fails or is already active.

  ```lua
  aty.sendNotify("Purchased", "You can't do this now!", "error", 8000)
  ```
