> 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-bounty-system/exports-and-events.md).

# 📤 Exports & Events

This section explains all available **exports and events** for `BrosDev-BountySystem`, allowing developers to integrate the bounty system with other scripts, jobs, or custom systems.

***

## 🖥️ Server-Side Exports

Use these exports on the **server side only**.

***

### 📊 Get All Active Bounties

Returns a full list of currently active bounties.

```lua
local bounties = exports['BrosDev-BountySystem']:GetActiveBounties()
```

📌 Returns:

* Table of all active bounty records
* Includes target info, amount, status, expiry, etc.

***

### 🎯 Check If Player Has Bounty

Check if a specific citizen ID has an active bounty.

```lua
local isBountied = exports['BrosDev-BountySystem']:IsPlayerBountied(cid)
```

📌 Returns:

* `true` → player has active bounty
* `false` → no bounty found

***

### 🧾 Get Bounty By ID

Fetch a specific bounty using its database ID.

```lua
local bounty = exports['BrosDev-BountySystem']:GetBountyData(bountyId)
```

📌 Returns:

* Full bounty object
* `nil` if not found

***

### 🎯 Get Bounty By Target CID

Fetch active bounty using target citizen ID.

```lua
local bounty = exports['BrosDev-BountySystem']:GetBountyByTarget(cid)
```

📌 Returns:

* Active bounty table
* `nil` if none exists

***

### 💰 Add Wallet Balance (External Use)

Add money directly to a player’s bounty wallet.

```lua
exports['BrosDev-BountySystem']:AddWalletBalance(cid, amount, note)
```

📌 Parameters:

* `cid` → citizen ID
* `amount` → amount to add
* `note` → optional description

***

### 💸 Remove Wallet Balance

Remove money from a player’s bounty wallet.

```lua
exports['BrosDev-BountySystem']:RemoveWalletBalance(cid, amount, note)
```

***

### 📊 Get Wallet Balance

Retrieve current wallet balance.

```lua
local balance = exports['BrosDev-BountySystem']:GetWalletBalance(cid)
```

***

### 🧑‍💻 Check If Player Is In Party

```lua
local party = exports['BrosDev-BountySystem']:GetPlayerParty(cid)
```

📌 Returns:

* Party data table if in a party
* `nil` if not in any party

***

### 🏆 Get Leaderboard Data

```lua
local data = exports['BrosDev-BountySystem']:GetLeaderboard()
```

📌 Returns:

* Ranked list of top bounty hunters

***

## 🖥️ Client-Side Exports

Use these exports on the **client side only**.

***

### 📱 Open Bounty Tablet

Manually open the bounty tablet UI.

```lua
exports['BrosDev-BountySystem']:OpenTablet()
```

***

### ❌ Close Tablet UI

Force close the bounty UI.

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

***

### 📲 Check If Tablet Is Open

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

📌 Returns:

* `true` → UI is open
* `false` → UI is closed

***

### 🎯 Show Target Tracker UI (Optional Hook)

```lua
exports['BrosDev-BountySystem']:ShowTracker(coords, time)
```

📌 Used for:

* Custom tracking systems
* External GPS integrations

***

## 🔔 Events (Server → Client)

***

### 💀 Bounty Claimed Event (Server)

Triggered when a bounty is successfully completed.

```lua
AddEventHandler('BrosDev-BountySystem:Server:OnBountyClaimed', function(data)
    -- data.bountyId
    -- data.targetCid
    -- data.killerCid
    -- data.killerSrc
    -- data.amount
    -- data.payout
end)
```

***

### 💀 Bounty Claimed Event (Client)

Broadcast to all players when a bounty is claimed.

```lua
AddEventHandler('BrosDev-BountySystem:Client:OnBountyClaimed', function(data)
    -- data.bountyId
    -- data.targetCid
    -- data.killerName
    -- data.amount
end)
```

***

### 🧠 Bounty Created Event

```lua
AddEventHandler('BrosDev-BountySystem:Server:OnBountyCreated', function(data)
    -- data.targetCid
    -- data.amount
    -- data.placedBy
end)
```

***

### ❌ Bounty Cancelled Event

```lua
AddEventHandler('BrosDev-BountySystem:Server:OnBountyCancelled', function(data)
    -- data.bountyId
    -- data.refund
end)
```

***

### 🧑 Party Created Event

```lua
AddEventHandler('BrosDev-BountySystem:Server:OnPartyCreated', function(data)
    -- data.partyId
    -- data.leaderCid
end)
```

***

### ⚠️ Notes

* All exports are **safe server-side guarded**
* Do NOT modify returned tables directly
* Always use exports for external integrations (jobs, gangs, police systems)
* Events are **non-blocking and async safe**
