> 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/plugins/ak47_lib/integration/server.md).

# Server

This section completes the API reference by covering Inventory, Server-Side Vehicle Keys, and Third-Party Banking integrations. These functions are located in `integration/server/` and exposed via the main `Lib47` object.

### Inventory

The lib provides a unified API for managing player inventories.

#### `Lib47.AddItem`

Adds an item to the player's inventory. Handles slot and metadata for supported inventories.

```lua
--- @param source number Player Server ID
--- @param item string Item name
--- @param amount number Count
--- @param slot number|nil (Optional) Specific slot
--- @param meta table|nil (Optional) Item metadata
--- @return boolean Success
local success = Lib47.AddItem(source, 'water', 5, nil, { quality = 100 })
```

#### `Lib47.RemoveItem`

Removes an item from the player's inventory.

```lua
--- @param source number Player Server ID
--- @param item string Item name
--- @param amount number Count
--- @return boolean Success
local success = Lib47.RemoveItem(source, 'water', 1)
```

#### `Lib47.GetInventoryItem`

Gets the count of a specific item in the player's inventory.

```lua
--- @param source number Player Server ID
--- @param item string Item name
--- @return number Count
local count = Lib47.GetInventoryItem(source, 'plastic')
```

#### `Lib47.HasEnoughItem`

Checks if the player has *at least* the specified amount of an item.

```lua
--- @param source number
--- @param item string
--- @param amount number
--- @return boolean
if Lib47.HasEnoughItem(source, 'money', 500) then
    print("Player can pay!")
end
```

#### `Lib47.CanCarryItem`

Checks if the player has enough weight/space to carry the item (Crucial for Ox/QB/QS).

```lua
--- @param source number
--- @param item string
--- @param amount number
--- @return boolean
if Lib47.CanCarryItem(source, 'stone', 10) then
    Lib47.AddItem(source, 'stone', 10)
else
    Lib47.Notify(source, "Inventory full!", "error")
end
```

#### `Lib47.GetItems`

Returns the server's master list of items (definitions).

```lua
--- @return table Key-value pair of items
local items = Lib47.GetItems()
print(items['water'].label)
```

#### `Lib47.GetItemLabel`

Returns the label of a specific item.

```lua
--- @param item string Item name
--- @return string Label
local label = Lib47.GetItemLabel('sandwich') -- Returns "Sandwich"
```

#### `Lib47.CreateUseableItem`

Registers a usable item callback.

```lua
--- @param item string Item name
--- @param cb function Callback function(source, item)
Lib47.CreateUseableItem('bandage', function(source, item)
    Lib47.RemoveItem(source, 'bandage', 1)
    Lib47.Notify(source, "Used Bandage", "success")
end)
```

***

### Vehicle Keys (Server)

These functions allow you to give or remove vehicle keys directly from the server side.

#### `Lib47.GiveVehicleKey`

Gives keys for a specific vehicle to a player.

```lua
--- @param source number Player Server ID
--- @param plate string Vehicle Plate
--- @param vehNetId number Network ID of the vehicle entity
--- @param virtual boolean (Optional) Give temporary/virtual keys
Lib47.GiveVehicleKey(source, "ABC 123", vehNetId, false)
```

#### `Lib47.RemoveVehicleKey`

Removes keys for a specific vehicle from a player.

```lua
--- @param source number Player Server ID
--- @param plate string Vehicle Plate
--- @param vehNetId number Network ID of the vehicle entity
--- @param virtual boolean (Optional) Remove temporary/virtual keys
Lib47.RemoveVehicleKey(source, "ABC 123", vehNetId, false)
```

***

### Banking Integration

it is important to note that the Integration layer (`integration/server/banking.lua`) extends these functions to support third-party banking resources automatically.

#### `Lib47.GetSocietyMoney`

Retrieves the current available balance of a specific job or society account.

```lua
--- @param job string
local balance = Lib47.GetSocietyMoney('police')
print(balance)
```

#### `Lib47.AddSocietyMoney`

Deposits funds into a specific job or society account.

```lua
--- @param job string
--- @param amount number
Lib47.AddSocietyMoney('police', 5000)
```

#### `Lib47.RemoveSocietyMoney`

Withdraws or removes funds from a specific job or society account.

```lua
--- @param job string
--- @param amount number
Lib47.RemoveSocietyMoney('police', 200)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.menanak47.com/plugins/ak47_lib/integration/server.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
