> For the complete documentation index, see [llms.txt](https://docs.sourcedev.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sourcedev.pro/src-billing/server-functions.md).

# Server Functions

This page provides detailed information about the functions available in the Server-side Bridge (`bridge/server.lua`).

## Player Management

### `Bridge.GetPlayer(source)`

Retrieves the framework's player object for the given server ID.

* **Returns:** `table` (Player Object)

### `Bridge.GetIdentifier(source)`

Retrieves the unique identifier for the player.

* **Returns:** `string`

### `Bridge.GetPlayerNameServer(source)`

Retrieves the character name on the server side.

* **Returns:** `string`

***

## Money & Transactions

### `Bridge.GetPlayerBank(source)`

Gets the bank balance of a player.

* **Returns:** `number`

### `Bridge.GetPlayerCash(source)`

Gets the cash balance of a player.

* **Returns:** `number`

### `Bridge.RemoveMoney(source, amount, type)`

**CRITICAL:** Deducts money from a player.

* **Arguments:**
  * `source` (number): Player server ID.
  * `amount` (number): Amount to remove.
  * `type` (string): 'bank' or 'cash'.
* **Returns:** `boolean` (True if successful, False if insufficient funds or error)

### `Bridge.AddMoney(source, amount, type)`

Adds money to a player's account.

* **Arguments:**
  * `source` (number): Player server ID.
  * `amount` (number): Amount to add.
  * `type` (string): 'bank' or 'cash'.
* **Returns:** `boolean`

***

## Permission Checks

### `Bridge.IsJobBossServer(source, jobName)`

Checks if a player is the boss of a specific job.

* **Returns:** `boolean`

### `Bridge.GetAllPlayers()`

Returns a list of all currently online players.

* **Returns:** `table`

***

## Internal Utilities

### `Bridge.RegisterServerCallback(name, callback)`

Registers a server-side callback that can be triggered from the client.

### `Bridge.TriggerClientEvent(name, target, ...)`

Wrapper for TriggerClientEvent to maintain consistency.

***

## Example Usage

### Safe Money Removal

```lua
local success = Bridge.RemoveMoney(source, 500, 'bank')
if success then
    -- Proceed with the transaction
else
    -- Notify player they can't afford it
end
```

### Checking for Online Player

```lua
local identifier = "CITIZEN_ID"
local target = Bridge.GetPlayerByIdentifier(identifier)
if target then
    print("Player is online with source: " .. target.source)
end
```
