> For the complete documentation index, see [llms.txt](https://bros-development.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bros-development.gitbook.io/documentation/scripts/brosdev-daily-rewards/exports-and-events.md).

# 📤 Exports & Events

BrosDev-DailyRewards includes multiple exports that allow other resources to interact with the reward system directly.

These exports can be used for:

* Opening the UI manually
* Forcing rewards
* Reading player reward progress
* Integrating rewards into other scripts
* Creating custom reward flows

***

## 🖥️ Server-Side Exports

### Open Reward UI

Open the Daily Rewards UI for a player.

```lua
exports['BrosDev-DailyRewards']:OpenUI(src)
```

#### Example

```lua
RegisterCommand('daily', function(source)
    exports['BrosDev-DailyRewards']:OpenUI(source)
end)
```

***

### Force Claim Reward

Force a player to claim a specific reward day.

Returns:

* `success` → boolean
* `errorMessage` → string or nil

```lua
local success, err = exports['BrosDev-DailyRewards']:ForceClaim(src, dayNumber)
```

#### Example

```lua
local success, err = exports['BrosDev-DailyRewards']:ForceClaim(source, 7)

if success then
    print('Day 7 reward claimed successfully.')
else
    print(err)
end
```

***

### Get Player Reward Data

Returns full reward progression data for a player.

```lua
local data = exports['BrosDev-DailyRewards']:GetPlayerData(src)
```

#### Returned Data

```lua
{
    currentDay = 5,
    currentStreak = 5,
    totalClaimed = 4,
    xp = 350,
    level = 2,
    nextClaim = 1748580000,
}
```

#### Example

```lua
local data = exports['BrosDev-DailyRewards']:GetPlayerData(source)

if data then
    print(('Player is on Day %s'):format(data.currentDay))
end
```

***

### Set Reward Programmatically

Create or replace rewards for a specific day using Lua.

```lua
exports['BrosDev-DailyRewards']:SetReward(dayNumber, rewardTable)
```

#### Example

```lua
exports['BrosDev-DailyRewards']:SetReward(10, {
    type  = 'money_cash',
    label = '$10,000 Cash',
    data  = {
        amount = 10000
    },
    is_milestone = true,
})
```

***

### Reset Player Progress

Reset a player back to Day 1.

```lua
exports['BrosDev-DailyRewards']:ResetPlayer(src)
```

#### Example

```lua
exports['BrosDev-DailyRewards']:ResetPlayer(source)
```

***

## 🎮 Client-Side Exports

### Open Reward UI

Open the Daily Rewards panel from client-side scripts.

```lua
exports['BrosDev-DailyRewards']:OpenUI()
```

#### Example

```lua
RegisterCommand('rewards', function()
    exports['BrosDev-DailyRewards']:OpenUI()
end)
```

***

### Close Reward UI

Force close the UI.

```lua
exports['BrosDev-DailyRewards']:CloseUI()
```

***

### Check If UI Is Open

Returns whether the rewards panel is currently open.

```lua
local isOpen = exports['BrosDev-DailyRewards']:IsOpen()
```

#### Example

```lua
if exports['BrosDev-DailyRewards']:IsOpen() then
    print('Rewards UI already open')
end
```

***

## 🔄 Example Integrations

### Open Rewards When Player Spawns

```lua
AddEventHandler('playerSpawned', function()
    exports['BrosDev-DailyRewards']:OpenUI()
end)
```

***

### Give Reward Through Another Script

```lua
RegisterNetEvent('myresource:rewardPlayer', function()
    local src = source

    local success = exports['BrosDev-DailyRewards']:ForceClaim(src, 1)

    if success then
        print('Reward granted.')
    end
end)
```

***

### Check Player Streak

```lua
RegisterNetEvent('myresource:checkDaily', function()
    local src = source
    local data = exports['BrosDev-DailyRewards']:GetPlayerData(src)

    if data then
        print(('Current streak: %s'):format(data.currentStreak))
    end
end)
```

***

## ⚠️ Notes

* Most exports are server-side only.
* `ForceClaim()` still respects reward validation and logging.
* Export names are case-sensitive.
* Ensure the resource name remains exactly:

```cfg
ensure BrosDev-DailyRewards
```

Changing the resource folder name will break exports unless updated manually.
