> For the complete documentation index, see [llms.txt](https://titans-productions.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://titans-productions.gitbook.io/documentation/redm/utility-scripts/tp-containers/development-api/server.md).

# Server

### Events

1. Register custom container - the specified event should only be called once to register this custom container and not multiple times.

```lua
--- @param name - requires a string (the required name to set for this custom container (such as: Motel Room #1)).
--- @param weight - requires an integer value (the required total maximum weight of the container in KG - set to -1 for no weight limit).
--- @param create - requires a boolean value (Set to true for creating (inserting) into the sql the registered custom container or not. If you set it to false, the container will remain active only while server has not yet restarted. This allows to create non-permanent storages).
TriggerEvent("tp_containers:server:registerCustomContainer", name, weight, create)
```

2. Un-register custom container

```lua
--- @param name - requires a string (the required custom container name).
TriggerEvent("tp_containers:server:unregisterCustomContainer", name)
```

3. Upgrade custom container weight

```lua
--- @param containerId - requires an integer value (The required custom container ID which is located on tp_containers sql table and can be found by using GetContainerIdByFirstNameResult export - this is not the container name).
--- @param extraWeight - requires an integer value (The extra weight to add on an existing container).
TriggerEvent("tp_containers:server:upgradeContainerInventoryWeight", containerId, extraWeight) -- Server side to server side.
```

4. Open custom container by its ID.

```lua
--- @param source - requires an integer value (the online player id).
--- @param containerId - requires an integer value (The required custom container ID which is located on tp_containers sql table and can be found by using GetContainerIdByFirstNameResult export - this is not the container name).
--- @param header - requires a string (If the header is not placed, it will select as the custom inventory container title the default name that has been created in first place, otherwise it will set as title the selected / input text).
--- @param cb - requires a boolean value (Set to true to disable transferring contents from main inventory to container storage).
TriggerClientEvent("tp_containers:client:openInventoryContainerById", source, containerId, header, cb) -- Server side to client side.
```

### Exports

1. Retrieve the Id of a created container name.

```lua
--- @param containerName - requires a string value (The custom created container that has been created by a name for retrieving the id).
local id = exports.tp_containers:GetContainerIdByFirstNameResult(containerName)
```
