# sm.container.spend

Removes a quantity of a given item from a container.

**Kind:** Function

**Environments:** Game

## Game

``` { .lua .api-signature }
sm.container.spend( container, itemUuid, quantity, mustSpendAll?, avoidSlot? )
```

[Open the full Game reference](../Game-Script-Environment/Static-Functions/sm.container.md#spend)

**Availability:** Server only

**Parameters:**

| Name | Type | Description |
| --- | --- | --- |
| `container` | [Container](../Game-Script-Environment/Userdata/Container.md) | The container. |
| `itemUuid` | [Uuid](../Game-Script-Environment/Userdata/Uuid.md) | The uuid of the item. |
| `quantity` | integer | The number of items. |
| `mustSpendAll` *(optional)* | boolean | If true, only remove items if there are enough. If false, remove as many items as possible. Defaults to true. (Optional) |
| `avoidSlot` *(optional)* | integer | If the spending should try and avoid a specific inventory slot if the resource is available in inventory. (Optional) |

**Returns:**

| Type | Description |
| --- | --- |
| integer | The number of items successfully removed. |
