> 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-wig-snatch/events.md).

# Events

***

### Client Events

<details>

<summary>nayzeee-wigsnatch:startSnatch</summary>

Initiates the wig snatching process.

```lua
TriggerEvent('nayzeee-wigsnatch:startSnatch', targetPlayerId)
```

**Parameters:**

| Parameter        | Type   | Description             |
| ---------------- | ------ | ----------------------- |
| `targetPlayerId` | number | Target player server ID |

</details>

<details>

<summary>nayzeee-wigsnatch:snatchAttempt</summary>

Notifies victim of snatch attempt (triggers defense minigame).

```lua
TriggerClientEvent('nayzeee-wigsnatch:snatchAttempt', victimId, snatcherId)
```

</details>

<details>

<summary>nayzeee-wigsnatch:snatchSuccess</summary>

Called when snatch is successful.

```lua
TriggerClientEvent('nayzeee-wigsnatch:snatchSuccess', snatcherId, victimId)
```

</details>

<details>

<summary>nayzeee-wigsnatch:snatchFailed</summary>

Called when snatch fails.

```lua
TriggerClientEvent('nayzeee-wigsnatch:snatchFailed', snatcherId, reason)
```

**Reasons:**

* `'defended'` - Victim defended successfully
* `'minigame'` - Snatcher failed minigame
* `'cancelled'` - Action was cancelled

</details>

<details>

<summary>nayzeee-wigsnatch:removeHair</summary>

Removes hair from victim's ped.

```lua
TriggerClientEvent('nayzeee-wigsnatch:removeHair', victimId)
```

</details>

***

### Server Events

<details>

<summary>nayzeee-wigsnatch:attemptSnatch</summary>

Server validation for snatch attempt.

```lua
TriggerServerEvent('nayzeee-wigsnatch:attemptSnatch', targetId)
```

</details>

<details>

<summary>nayzeee-wigsnatch:snatchComplete</summary>

Reports successful snatch to server.

```lua
TriggerServerEvent('nayzeee-wigsnatch:snatchComplete', victimId)
```

</details>

<details>

<summary>nayzeee-wigsnatch:defended</summary>

Reports victim defended.

```lua
TriggerServerEvent('nayzeee-wigsnatch:defended', snatcherId)
```

</details>

***

### Listenable Events

<details>

<summary>nayzeee-wigsnatch:onSnatch</summary>

Triggered when a wig is successfully snatched.

```lua
AddEventHandler('nayzeee-wigsnatch:onSnatch', function(snatcherId, victimId, wigType)
    print('Player ' .. snatcherId .. ' snatched wig from ' .. victimId)
end)
```

**Parameters:**

| Parameter    | Type   | Description               |
| ------------ | ------ | ------------------------- |
| `snatcherId` | number | Snatcher player ID        |
| `victimId`   | number | Victim player ID          |
| `wigType`    | string | Type of wig/hair snatched |

</details>

<details>

<summary>nayzeee-wigsnatch:onDefend</summary>

Triggered when a victim successfully defends.

```lua
AddEventHandler('nayzeee-wigsnatch:onDefend', function(victimId, snatcherId)
    print('Player ' .. victimId .. ' defended against snatch!')
end)
```

</details>
