# Stock System

## 📦 Stock System

ELENASHOP includes a per-item stock tracking system with visual indicators and auto-restock.

***

### Enable or Disable

\-- Enable stock system Config.EnableStock = true

\-- Disable stock system (all items unlimited) Config.EnableStock = false

***

### Per-Item Stock Values

Set stock in your store items:

items = { { name = 'burger', label = 'Burger', price = 15, category = 'food', stock = -1 }, { name = 'pizza', label = 'Pizza', price = 20, category = 'food', stock = 50 }, { name = 'rare\_item', label = 'Rare', price = 500, category = 'other', stock = 3 }, }

| Stock Value | Meaning                      |
| ----------- | ---------------------------- |
| -1          | Unlimited (no limit)         |
| 0           | Out of stock (cannot buy)    |
| 1-5         | Low stock (yellow indicator) |
| 6+          | In stock (green indicator)   |

***

### Visual Indicators

The UI shows stock status on each product card:

| Status           | Color  | Text         |
| ---------------- | ------ | ------------ |
| In stock (6+)    | Green  | 20 Stokta    |
| Low stock (1-5)  | Yellow | 3 Stokta     |
| Out of stock (0) | Red    | Tukendi      |
| Unlimited (-1)   | Hidden | No indicator |

***

### Auto-Restock

\-- Restock all items every hour (3600 seconds) Config.RestockTime = 3600

\-- Restock every 30 minutes Config.RestockTime = 1800

\-- Disable auto-restock Config.RestockTime = 0

When restock triggers, all stock values reset to their original config.lua values.

***

### Stock After Purchase

When a player buys an item:

1. Stock decreases on the server
2. Updated stock is sent to the UI
3. Product card updates in real-time
4. If stock reaches 0, item becomes disabled

Stock does NOT persist after server restart. It resets to config values.


---

# Agent Instructions: 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:

```
GET https://elena-scripts.gitbook.io/elenascripts/economy/shop/stock-system.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
