# Usage

## Create Ped Export

#### Export

```lua
exports['five-pedmanager']:createPed(uniquename, pedmodel, vector4, freeze, invincible, animDict, animName)
```

<details>

<summary>Parameters</summary>

**Parameters**

* **`uniquename`**: *(string)*\
  A unique identifier for the ped. This name is used to reference the ped in other functions.
* **`pedmodel`**: *(string)*\
  The model name of the ped to be created. This should be a valid ped model string from GTA V (e.g., `a_m_m_farmer_01` for a male farmer).
* **`vector4`**: *(vector4)*\
  The position and heading where the ped will be spawned. The `vector4` includes the x, y, z coordinates and the heading (rotation).
* **`freeze`**: *(boolean)*\
  Determines whether the ped's position should be frozen, preventing it from moving.
* **`invincible`**: *(boolean)*\
  If set to `true`, the ped will be invincible, meaning it cannot be harmed or killed.
* **`animDict`**: *(string)*\
  The animation dictionary to be used for the ped. This is a collection of animations in GTA V that the ped can perform.
* **`animName`**: *(string)*\
  The specific animation name from the `animDict` that the ped will perform.\
  \&#xNAN;**`return`**: *(boolean)*

</details>

Example Usage

<pre class="language-lua"><code class="lang-lua"><strong>local ped = exports['five-pedmanager']:createPed(
</strong>    'farmer_1', 
    'a_m_m_farmer_01', 
    vector4(122.2, 97.2, 81.43, 180), 
    true, 
    true, 
    'amb@world_human_hang_out_street@male_a@idle_a', 
    'idle_a'
)
</code></pre>

{% hint style="info" %}
**Notes**

* Ensure that the `pedmodel` and `animDict/animName` are valid strings, as incorrect values may cause errors or the ped not to spawn.
* The `freeze` and `invincible` options are useful for creating static NPCs that serve specific roles, such as shopkeepers or mission giver
  {% endhint %}

## Freeze Ped Export

#### Export

```lua
exports['five-pedmanager']:pedFreeze(uniquename, freeze)
```

<details>

<summary>Parameters</summary>

**Parameters**

* **`uniquename`**: *(string)*\
  The unique identifier of the ped that you want to freeze or unfreeze. This name should match the one used when creating the ped with the `createPed` function.
* **`freeze`**: *(boolean)*\
  A boolean value that determines whether the ped should be frozen or not.
  * `true`: The ped will be frozen in place, unable to move.
  * `false`: The ped will be unfrozen, allowing it to move freely.

</details>

#### Example Usage

```lua
exports['five-pedmanager']:pedFreeze('farmer_1', false)
```

{% hint style="info" %}
**Notes**

* The `uniquename` must correspond to a ped that has already been created using the `createPed` function. If the name is incorrect or does not match any existing peds, the function will not have any effect.
* This function is particularly useful for scenarios where the behavior of an NPC needs to change dynamically, such as making an NPC start moving after a specific event triggers.
  {% endhint %}

## Ped Dress Up Export

#### Export

```lua
exports['five-pedmanager']:peddressup('farmer_1', componentId, drawableId, textureId)
```

<details>

<summary>Parameters</summary>

**Parameters**

* **`uniquename`**: *(string)*\
  The unique identifier of the ped you want to dress up. This name should match the one used when creating the ped with the `createPed` function.
* **`componentId`**: *(integer)*\
  The ID of the component you want to change. Components represent different parts of the ped's outfit or appearance (e.g., torso, legs, shoes). Each component has a specific ID:
  * `0`: Head
  * `1`: Mask
  * `2`: Hair
  * `3`: Torso
  * `4`: Legs
  * `5`: Hands
  * `6`: Shoes
  * `7`: Accessories
  * `8`: Undershirt
  * `9`: Body Armor
  * `10`: Decals
  * `11`: Tops
* **`drawableId`**: *(integer)*\
  The ID of the drawable (specific model) to be applied to the selected component. This determines the specific item or appearance for that component.
* **`textureId`**: *(integer)*\
  The ID of the texture to be applied to the drawable. Textures can change the color or pattern of the drawable. Setting this to `0` usually applies the default texture.

</details>

#### Example Usage

```lua
exports['five-pedmanager']:peddressup('farmer_1', 3, 5, 0)
```

{% hint style="info" %}
**Notes**

* The `uniquename` must correspond to a ped that has already been created using the `createPed` function.
* Ensure that the `componentId`, `drawableId`, and `textureId` values are valid for the ped model you are customizing. Incorrect values may result in no visible change or unexpected appearance.
* This function is particularly useful for giving peds a specific look, which can be important for role-playing scenarios, missions, or thematic environments in your server.
  {% endhint %}

## Ped Emote Export

#### Export

```lua
exports['five-pedmanager']:pedemote(uniquename, animDict, animName)
```

<details>

<summary>Parameters</summary>

**Parameters**

* **`uniquename`**: *(string)*\
  The unique identifier of the ped that you want to perform the emote. This name should match the one used when creating the ped with the `createPed` function.
* **`animDict`**: *(string)*\
  The animation dictionary that contains the emote or animation you want the ped to perform. This is a collection of animations in GTA V that the ped can perform.
* **`animName`**: *(string)*\
  The specific name of the animation within the `animDict` that you want the ped to perform.

</details>

#### Example Usage

```lua
exports['five-pedmanager']:pedemote('farmer_1', 'amb@world_human_drinking@coffee@male@base', 'base')
```

{% hint style="info" %}
**Notes**

* The `uniquename` must correspond to a ped that has already been created using the `createPed` function.
* Ensure that the `animDict` and `animName` are valid and correspond to an existing animation in GTA V. If the values are incorrect, the ped will not perform the animation.
* This function is particularly useful for creating immersive environments where NPCs are engaged in specific activities, enhancing the realism of your server.
  {% endhint %}

## Get Ped Emote Export

#### Export

```lua
exports['five-pedmanager']:getpedemote(uniquename, anim)
```

<details>

<summary>Parameters</summary>

**Parameters**

* **`uniquename`**: *(string)*\
  The unique identifier of the ped whose animation you want to retrieve. This name should match the one used when creating the ped with the `createPed` function.
* **`anim`**: *(string)*\
  The name of the animation you want to check or retrieve. This parameter allows you to specify which animation to query for the ped.

**Return Value**

* **`pedanim`**: *(string)*\
  The function returns the current animation name if the ped is performing the specified animation. If the ped is not performing the animation, it may return `nil` or another indicative value.

</details>

#### Example Usage

```lua
local pedanim = exports['five-pedmanager']:getpedemote('farmer_1', 'animName')
```

{% hint style="info" %}
**Notes**

* The `uniquename` must correspond to a ped that has already been created using the `createPed` function.
* The `anim` parameter should be a valid animation name that corresponds to the animations available to the ped.
* This function is particularly useful in scenarios where the behavior of an NPC is dependent on its current animation state, such as conditional actions or interaction triggers.
  {% endhint %}
