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.

--- @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.

--- @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.

--- @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.

--- @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).

--- @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).

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

Lib47.GetItemLabel

Returns the label of a specific item.

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

Lib47.CreateUseableItem

Registers a usable item callback.

--- @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.

--- @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.

--- @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.

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

Lib47.AddSocietyMoney

Deposits funds into a specific job or society account.

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

Lib47.RemoveSocietyMoney

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

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