> For the complete documentation index, see [llms.txt](https://nayzeee-dev.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nayzeee-dev.gitbook.io/docs/nayzeee-scripts/nayzeee-ped-menu/events.md).

# Events

***

### Client Events

<details>

<summary>nayzeee-pedmenu:client:openMenu</summary>

```lua
TriggerEvent('nayzeee-pedmenu:client:openMenu')
```

*Opens the ped selection menu for the player. Fetches player's saved peds from database and displays the UI.*

***

**Example:**

```lua
-- Open the ped menu from another script
TriggerEvent('nayzeee-pedmenu:client:openMenu')
```

</details>

<details>

<summary>nayzeee-pedmenu:client:selectSkin</summary>

```lua
TriggerEvent('nayzeee-pedmenu:client:selectSkin', pedModel)
```

*Changes the player's ped model to the specified model.*

***

**`pedModel`** *(string)*: The ped model name to apply (e.g., `'a_m_y_hipster_01'`, `'s_m_y_cop_01'`)

***

**Example:**

```lua
-- Change player to a specific ped
TriggerEvent('nayzeee-pedmenu:client:selectSkin', 'a_m_y_hipster_01')
```

</details>

***

### Server Events

<details>

<summary>nayzeee-pedmenu:server:deleteSkin</summary>

```lua
TriggerServerEvent('nayzeee-pedmenu:server:deleteSkin', model)
```

*Removes a ped model from the player's saved ped list.*

***

**`model`** *(string)*: The ped model name to remove from the player's list.

***

**Example:**

```lua
-- Remove a ped from player's list
TriggerServerEvent('nayzeee-pedmenu:server:deleteSkin', 'a_m_y_hipster_01')
```

</details>

<details>

<summary>nayzeee-pedmenu:server:addFav</summary>

```lua
TriggerServerEvent('nayzeee-pedmenu:server:addFav', model)
```

*Sets the specified ped model as the player's favorite ped.*

***

**`model`** *(string)*: The ped model name to set as favorite.

***

**Example:**

```lua
-- Set a ped as favorite
TriggerServerEvent('nayzeee-pedmenu:server:addFav', 's_m_y_cop_01')
```

</details>

<details>

<summary>nayzeee-pedmenu:server:removeFav</summary>

```lua
TriggerServerEvent('nayzeee-pedmenu:server:removeFav', model)
```

*Removes the favorite status from the player's favorite ped.*

***

**`model`** *(string)*: The ped model name to remove from favorites.

***

**Example:**

```lua
-- Remove favorite status
TriggerServerEvent('nayzeee-pedmenu:server:removeFav', 's_m_y_cop_01')
```

</details>

<details>

<summary>nayzeee-pedmenu:server:spawnFav</summary>

```lua
TriggerServerEvent('nayzeee-pedmenu:server:spawnFav')
```

*Requests the server to apply the player's favorite ped. Called automatically on player load if `Config.SpawnWithFavoritePed` is enabled.*

***

**Example:**

```lua
-- Manually trigger favorite ped spawn
TriggerServerEvent('nayzeee-pedmenu:server:spawnFav')
```

</details>

***

### Legacy Events (Backward Compatibility)

These events are maintained for backward compatibility with older versions:

| Legacy Event                           | Redirects To                        |
| -------------------------------------- | ----------------------------------- |
| `nayzeeedev-menuped:server:deleteSkin` | `nayzeee-pedmenu:server:deleteSkin` |
| `nayzeeedev-menuped:server:addFav`     | `nayzeee-pedmenu:server:addFav`     |
| `nayzeeedev-menu:ped:server:spawnFav`  | `nayzeee-pedmenu:server:spawnFav`   |

***

### Framework Events (Automatic)

The script automatically listens to framework events for spawning favorite peds:

#### QBCore

```lua
-- Listened automatically when Config.SpawnWithFavoritePed = true
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
    -- Triggers favorite ped spawn after delay
end)
```

#### ESX

```lua
-- Listened automatically when Config.SpawnWithFavoritePed = true
RegisterNetEvent('esx:playerLoaded', function()
    -- Triggers favorite ped spawn after delay
end)
```
