> For the complete documentation index, see [llms.txt](https://docs.menanak47.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.menanak47.com/multi-framework/ak47_hud/exports/server.md).

# Server

The `ak47_hud` server-side API provides powerful tools for external scripts to seamlessly interact with your core systems. These exports allow other resources—such as heist scripts, admin menus, minigames, and racing systems—to bypass standard UI requirements, sync state globally, and manipulate data safely.

> Note: All functions below are Server-Side exports. You must call them from a server script using `exports['ak47_hud']:FunctionName()`.

### 💬 Chat System API

Manage player chat groups programmatically. These exports interact directly with the local cache and database, automatically refreshing the UI for all relevant players without requiring them to type commands or enter passwords.

#### `GetPlayerChatGroup`

Instantly checks the server's cache to see which chat group a player is currently in (0 database queries).

| **Parameter** | **Type** | **Description**         |
| ------------- | -------- | ----------------------- |
| `source`      | `number` | The player's server ID. |

Returns: `string` (The group name) or `nil` if not in a group.

```lua
local groupName = exports['ak47_hud']:GetPlayerChatGroup(source)

if groupName then
    print("Player is currently in group: " .. groupName)
end
```

#### `CreatePlayerGroup`

Creates a brand new chat group via script, saves it to the database, and automatically assigns the target player as the owner.

| **Parameter** | **Type** | **Description**                              |
| ------------- | -------- | -------------------------------------------- |
| `groupName`   | `string` | The desired name for the group.              |
| `password`    | `string` | The group's password.                        |
| `ownerSrc`    | `number` | The server ID of the player who will own it. |

```lua
-- Great for automatically creating a secure group for a heist crew
exports['ak47_hud']:CreatePlayerGroup('FleecaCrew', 'secret123', source)
```

#### `AddPlayerToGroup`

Forces an online player into a specific group. This completely bypasses the password requirement, making it perfect for external script integrations.

| **Parameter** | **Type** | **Description**                     |
| ------------- | -------- | ----------------------------------- |
| `targetSrc`   | `number` | The server ID of the player to add. |
| `groupName`   | `string` | The name of the group.              |

<pre class="language-lua"><code class="lang-lua"><strong>-- Force a player into the 'FleecaCrew' group silently
</strong>exports['ak47_hud']:AddPlayerToGroup(targetPlayerId, 'FleecaCrew')
</code></pre>

#### `RemovePlayerFromGroup`

Removes an online player from whatever group they are currently in. Automatically updates the UI for the removed player and all remaining members.

| **Parameter** | **Type** | **Description**                        |
| ------------- | -------- | -------------------------------------- |
| `targetSrc`   | `number` | The server ID of the player to remove. |

<pre class="language-lua"><code class="lang-lua"><strong>-- Kick a player out of their active group (e.g., when they go off-duty)
</strong>exports['ak47_hud']:RemovePlayerFromGroup(source)
</code></pre>

### 🛠️ Utilities & Systems API

Use these exports to interact with the HUD's notification, kill feed, and vehicle systems programmatically.

#### `SendSystemMessage`

Sends a standardized, formatted system message directly to a specific player's chat window.

| **Parameter** | **Type** | **Description**                                                                             |
| ------------- | -------- | ------------------------------------------------------------------------------------------- |
| `source`      | `number` | The player ID to send the message to.                                                       |
| `message`     | `string` | The text to display.                                                                        |
| `rgb`         | `table`  | *(Optional)* `{R, G, B}` color table. Defaults to a standard system green `{52, 211, 153}`. |

```lua
-- Send a custom red system alert
exports['ak47_hud']:SendSystemMessage(source, "You have entered a restricted zone!", {255, 0, 0})
```

#### `BroadcastCustomKill`

Broadcasts a custom kill to the Kill Feed UI for all players on the server. Ideal for paintball, laser tag, arena minigames, or custom death scripts that bypass native damage events.

| **Parameter** | **Type**        | **Description**                                         |
| ------------- | --------------- | ------------------------------------------------------- |
| `killerName`  | `string`        | Display name of the attacker.                           |
| `killerId`    | `number`        | Server ID of the attacker.                              |
| `victimName`  | `string`        | Display name of the victim.                             |
| `victimId`    | `number`        | Server ID of the victim.                                |
| `weaponHash`  | `number/string` | The weapon hash or weapon name.                         |
| `isHeadshot`  | `boolean`       | `true` to display the headshot icon and play the sound. |

<pre class="language-lua"><code class="lang-lua"><strong>-- Broadcast a custom minigame kill globally
</strong>exports['ak47_hud']:BroadcastCustomKill("SniperGod99", 5, "NoobMaster", 12, "WEAPON_SNIPERRIFLE", true)
</code></pre>

#### `SetVehicleNitro`

Sets the nitro level of a specific vehicle programmatically. This sets the global network state, immediately reflecting on the driver's HUD.

| **Parameter** | **Type** | **Description**                        |
| ------------- | -------- | -------------------------------------- |
| `netId`       | `number` | The network ID of the vehicle.         |
| `amount`      | `number` | The amount of nitro to set (0 to 100). |

```lua
-- Example: A racing script that refills a player's nitro when they hit a checkpoint
local veh = GetVehiclePedIsIn(GetPlayerPed(source), false)
local netId = NetworkGetNetworkIdFromEntity(veh)

exports['ak47_hud']:SetVehicleNitro(netId, 100)
```
