> 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/exports.md).

# Exports

***

### Client Exports

<details>

<summary>StartSnatch</summary>

Starts a snatch attempt on nearest valid target.

```lua
exports['nayzeee-wigsnatch']:StartSnatch()
```

**Returns:** `boolean` - Whether snatch was initiated

</details>

<details>

<summary>CanSnatch</summary>

Checks if player can currently snatch.

```lua
local canSnatch, reason = exports['nayzeee-wigsnatch']:CanSnatch()
```

**Returns:**

| Return      | Type    | Description                |
| ----------- | ------- | -------------------------- |
| `canSnatch` | boolean | Whether snatch is possible |
| `reason`    | string  | Reason if cannot snatch    |

**Reasons:**

* `'cooldown'` - On cooldown
* `'no_target'` - No valid target nearby
* `'invalid_gender'` - Target gender not allowed

</details>

<details>

<summary>GetCooldown</summary>

Gets remaining cooldown time.

```lua
local remaining = exports['nayzeee-wigsnatch']:GetCooldown()
```

**Returns:** `number` - Seconds remaining (0 if ready)

</details>

<details>

<summary>IsOnCooldown</summary>

Checks if player is on cooldown.

```lua
local onCooldown = exports['nayzeee-wigsnatch']:IsOnCooldown()
```

**Returns:** `boolean`

</details>

***

### Server Exports

<details>

<summary>GetPlayerStats</summary>

Gets snatch statistics for a player.

```lua
local stats = exports['nayzeee-wigsnatch']:GetPlayerStats(source)
```

**Returns:**

```lua
{
    snatched = number,   -- Successful snatches
    defended = number,   -- Times defended
    failed = number      -- Failed attempts
}
```

</details>

<details>

<summary>ResetCooldown</summary>

Resets a player's snatch cooldown.

```lua
exports['nayzeee-wigsnatch']:ResetCooldown(source)
```

</details>

<details>

<summary>GiveWigItem</summary>

Gives a wig item to player.

```lua
exports['nayzeee-wigsnatch']:GiveWigItem(source, wigType)
```

**Parameters:**

| Parameter | Type   | Description      |
| --------- | ------ | ---------------- |
| `source`  | number | Player server ID |
| `wigType` | string | Type of wig item |

</details>

***

### Integration Examples

#### ox\_target Integration

```lua
-- Add snatch option when targeting players
exports.ox_target:addGlobalPlayer({
    {
        name = 'snatch_wig',
        label = 'Snatch Wig',
        icon = 'fas fa-cut',
        distance = 2.0,
        canInteract = function(entity, distance, coords, name, bone)
            local canSnatch = exports['nayzeee-wigsnatch']:CanSnatch()
            return canSnatch
        end,
        onSelect = function(data)
            exports['nayzeee-wigsnatch']:StartSnatch()
        end
    }
})
```

#### Keybind Integration

```lua
-- Add keybind to snatch
RegisterKeyMapping('snatchwig', 'Snatch Wig', 'keyboard', 'G')
RegisterCommand('snatchwig', function()
    local canSnatch, reason = exports['nayzeee-wigsnatch']:CanSnatch()
    if canSnatch then
        exports['nayzeee-wigsnatch']:StartSnatch()
    else
        -- Notify reason
        lib.notify({ description = 'Cannot snatch: ' .. reason, type = 'error' })
    end
end, false)
```

#### Cooldown Display

```lua
-- Show cooldown in UI
CreateThread(function()
    while true do
        if exports['nayzeee-wigsnatch']:IsOnCooldown() then
            local remaining = exports['nayzeee-wigsnatch']:GetCooldown()
            -- Update UI with remaining time
        end
        Wait(1000)
    end
end)
```

#### Event Logging

```lua
-- Log all snatch events
AddEventHandler('nayzeee-wigsnatch:onSnatch', function(snatcher, victim, wigType)
    -- Log to database or Discord
    MySQL.insert('INSERT INTO snatch_logs (snatcher, victim, wig_type, timestamp) VALUES (?, ?, ?, ?)',
        { snatcher, victim, wigType, os.time() })
end)
```
