> For the complete documentation index, see [llms.txt](https://hyper-9.gitbook.io/hyper-inventory/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hyper-9.gitbook.io/hyper-inventory/exports/stash.md).

# ตู้เก็บของ (Stash)

เปิดแผงตู้ข้างกระเป๋าให้ผู้เล่น ใช้ทำท้ายรถ ตู้เซฟ ตู้บ้าน ตู้แก๊ง — ฝั่ง **server** ทั้งหมด

| Export                            | เมื่อไหร่ใช้                                                     |
| --------------------------------- | ---------------------------------------------------------------- |
| `OpenStashExternal`               | **แนะนำ** — resource ของคุณเก็บของและเซฟ DB เอง กระเป๋าแค่แสดงผล |
| `RefreshStash`                    | หลังเก็บ/หยิบสำเร็จ ส่งรายการของใหม่ให้ทุกคนที่เปิดตู้นี้        |
| `OpenStash`                       | ตู้ชั่วคราวในตัว เก็บใน RAM — restart แล้วของหาย                 |
| `GetStashItems` / `SetStashItems` | อ่าน/เขียนของในตู้ในตัว ถ้าอยากเซฟเอง                            |

![ตู้เก็บของ](https://3138376267-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4xHlkr2x1a8mZlrfuaa5%2Fuploads%2FUNBl7iiJkEDg42EyugOE%2F06_stash.png?alt=media)

## OpenStashExternal

```lua
exports["Hyper_Inventory"]:OpenStashExternal(playerId, opts)
```

| ฟิลด์ใน opts                      | ชนิด   | ความหมาย                                                                       |
| --------------------------------- | ------ | ------------------------------------------------------------------------------ |
| `id`                              | string | รหัสตู้ (จำเป็น) เช่น `"trunk_" .. plate`                                      |
| `label`                           | string | ชื่อบนหัวแผง                                                                   |
| `slots`                           | number | จำนวนช่อง                                                                      |
| `items`                           | table  | `{ {name, label, count}, ... }`                                                |
| `weight` / `maxWeight`            | number | น้ำหนักปัจจุบัน / สูงสุด (หลอดความจุ)                                          |
| `unitWeight` / `unitWeaponWeight` | number | น้ำหนักต่อชิ้น — ใช้ขึ้นไอคอนห้ามใส่เมื่อใส่ไม่ลง                              |
| `denyList`                        | table  | ชื่อไอเทมที่ห้ามใส่                                                            |
| `blockKinds`                      | table  | ชนิดที่ห้ามใส่: `'item'` / `'weapon'` / `'account'`                            |
| `events`                          | table  | `{ store = "...", take = "...", close = "..." }` ชื่อ event ฝั่ง server ของคุณ |

เมื่อผู้เล่นเก็บ/หยิบ กระเป๋าจะยิง event ให้ resource ของคุณ — ตรวจสิทธิ์ ย้ายของ เซฟ DB แล้วเรียก `RefreshStash`

| Event   | Argument                  |
| ------- | ------------------------- |
| `store` | `src, name, count, itype` |
| `take`  | `src, name, count, itype` |
| `close` | `src, id`                 |

ตัวอย่างจาก Hyper\_Garage (ท้ายรถ):

```lua
exports["Hyper_Inventory"]:OpenStashExternal(src, {
    id = "trunk_" .. plate,
    label = "ท้ายรถ " .. plate,
    slots = capS,
    weight = curW,
    maxWeight = maxW,
    unitWeight = 0.5,
    unitWeaponWeight = 5.0,
    denyList = Config.Trunk.ItemBlacklist or {},
    items = hyperItemList(plate),
    events = {
        store = "Hyper_Garage:trunkHyperStore",
        take = "Hyper_Garage:trunkHyperTake",
        close = "Hyper_Garage:trunkHyperClose",
    },
})

AddEventHandler("Hyper_Garage:trunkHyperStore", function(src, name, count, itype)
    -- ตรวจสิทธิ์ + ย้ายของ + เซฟ DB แล้ว:
    exports["Hyper_Inventory"]:RefreshStash(src, "trunk_" .. plate, hyperItemList(plate), curW)
end)
```

## RefreshStash

```lua
exports["Hyper_Inventory"]:RefreshStash(playerId, id, items, weight)
```

อัปเดตของในตู้ `id` และส่งให้ **ทุกคน** ที่เปิดตู้ใบนี้อยู่ `weight` ไม่ใส่ก็ได้

## OpenStash

```lua
exports["Hyper_Inventory"]:OpenStash(playerId, id, label, slots, maxWeight)
```

ตู้ในตัวของกระเป๋า เก็บใน RAM เท่านั้น — restart แล้วของหาย ใช้กับตู้ชั่วคราว หรือคู่กับ `GetStashItems` / `SetStashItems` ถ้าจะเซฟเอง

## GetStashItems / SetStashItems

```lua
local items = exports["Hyper_Inventory"]:GetStashItems(id)          -- { {name, label, count}, ... } หรือ nil
exports["Hyper_Inventory"]:SetStashItems(id, items, label, slots)
```

ใช้ได้เฉพาะตู้ในตัว (`OpenStash`) — ตู้ภายนอกคืน `nil` / ไม่ทำอะไร


---

# 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 following URL with the `ask` and `goal` query parameters:

```
GET https://hyper-9.gitbook.io/hyper-inventory/exports/stash.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `build a script that syncs our docs to a CMS` lets GitBook tailor the answer to that use case.

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.
