> For the complete documentation index, see [llms.txt](/llms.txt)

# GS2-Inventory スクリプト トリガー リファレンス

拡張スクリプトを呼び出すイベントトリガーのリファレンス



## トリガー

### acquire

アイテム入手
**関連するメソッド:**
acquireItemSetByUserId - ユーザーIDを指定してアイテムセットを入手
acquireItemSetWithGradeByUserId - ユーザーIDを指定して GS2-Grade にグレードを設定しつつ、アイテムセットを1つ入手


#### 同期実行スクリプト

アイテム入手処理の前に、スクリプトが同期実行されます。

##### Request

| | 型 | 説明 |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | ネームスペース |
| inventory | [Inventory](../sdk/#inventory) | インベントリ |
| itemSets | [ItemSet[]](../sdk/#itemset) | アイテムセットのリスト |
| acquireItemName | string | 入手したアイテムモデル名 |
| userId | string | ユーザーID |
| acquireCount | long | 入手数量 |
| expiresAt | long | 有効期限<br>UNIX 時間・ミリ秒 |

##### Result

|  | 型 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | アイテム入手を許可するか |
| overrideAcquireCount | int |  |  | 0 ~ 2147483645 | 実際に適用する入手量 |

##### 実装例


**Lua**
```lua

-- Request
local namespace = args.namespace
local inventory = args.inventory
local itemSets = args.itemSets
local acquireItemName = args.acquireItemName
local userId = args.userId
local acquireCount = args.acquireCount
local expiresAt = args.expiresAt

-- Business logic:
local permit = true
local overrideAcquireCount = 0

-- Result
result = {
  permit=permit,
  overrideAcquireCount=overrideAcquireCount
}
```


#### 非同期実行スクリプト

アイテム入手処理の後に、スクリプトが非同期実行されます。

##### Request

| | 型 | 説明 |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | ネームスペース |
| oldInventory | [Inventory](../sdk/#inventory) | 更新前のインベントリ |
| oldItemSets | [ItemSet[]](../sdk/#itemset) | 更新前のアイテムセットリスト |
| newInventory | [Inventory](../sdk/#inventory) | 更新後のインベントリ |
| newItemSets | [ItemSet[]](../sdk/#itemset) | 更新後のアイテムセットのリスト |
| acquireItemName | string | 入手したアイテムモデル名 |
| userId | string | ユーザーID |
| acquireCount | long | 入手数量 |
| overflowValue | long | 溢れた量 |
| expiresAt | long | 有効期限<br>UNIX 時間・ミリ秒 |


##### 実装例


**Lua**
```lua

-- Request
local namespace = args.namespace
local oldInventory = args.oldInventory
local oldItemSets = args.oldItemSets
local newInventory = args.newInventory
local newItemSets = args.newItemSets
local acquireItemName = args.acquireItemName
local userId = args.userId
local acquireCount = args.acquireCount
local overflowValue = args.overflowValue
local expiresAt = args.expiresAt

-- 非同期スクリプトは通常、API のレスポンスには影響を与えません。
-- ログ出力や分析、外部通知などに使用します。

result = {
}
```


---
  
### overflowDone

アイテム数が入手上限に当たり、入手できなかった数量の通知完了
**関連するメソッド:**
acquireItemSetByUserId - ユーザーIDを指定してアイテムセットを入手
acquireItemSetWithGradeByUserId - ユーザーIDを指定して GS2-Grade にグレードを設定しつつ、アイテムセットを1つ入手


#### 同期実行スクリプト

アイテム数が入手上限に当たり、入手できなかった数量の通知完了処理の前に、スクリプトが同期実行されます。

##### Request

| | 型 | 説明 |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | ネームスペース |
| inventory | [Inventory](../sdk/#inventory) | インベントリ |
| itemModel | [ItemModel](../sdk/#itemmodel) | アイテムモデル |
| userId | string | ユーザーID |
| overflowValue | long | 溢れた量 |


##### 実装例


**Lua**
```lua

-- Request
local namespace = args.namespace
local inventory = args.inventory
local itemModel = args.itemModel
local userId = args.userId
local overflowValue = args.overflowValue

-- Business logic:

-- Result
result = {
}
```


---
  
### consume

アイテム消費
**関連するメソッド:**
consumeItemSet - アイテムセットを消費
consumeItemSetByUserId - ユーザーIDを指定してアイテムセットを消費


#### 同期実行スクリプト

アイテム消費処理の前に、スクリプトが同期実行されます。

##### Request

| | 型 | 説明 |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | ネームスペース |
| inventory | [Inventory](../sdk/#inventory) | インベントリ |
| itemSets | [ItemSet[]](../sdk/#itemset) | アイテムセットのリスト |
| consumeItemName | string | 消費したアイテムモデル名 |
| userId | string | ユーザーID |
| consumeCount | long | 消費数量 |

##### Result

|  | 型 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | アイテム消費を許可するか |
| overrideConsumeCount | int |  |  | 0 ~ 2147483645 | 実際に適用する消費量 |

##### 実装例


**Lua**
```lua

-- Request
local namespace = args.namespace
local inventory = args.inventory
local itemSets = args.itemSets
local consumeItemName = args.consumeItemName
local userId = args.userId
local consumeCount = args.consumeCount

-- Business logic:
local permit = true
local overrideConsumeCount = 0

-- Result
result = {
  permit=permit,
  overrideConsumeCount=overrideConsumeCount
}
```


#### 非同期実行スクリプト

アイテム消費処理の後に、スクリプトが非同期実行されます。

##### Request

| | 型 | 説明 |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | ネームスペース |
| oldInventory | [Inventory](../sdk/#inventory) | 消費前のインベントリ |
| oldItemSets | [ItemSet[]](../sdk/#itemset) | 消費前のアイテムセットのリスト |
| newInventory | [Inventory](../sdk/#inventory) | 消費後のインベントリ |
| newItemSets | [ItemSet[]](../sdk/#itemset) | 消費後のアイテムセットのリスト |
| consumeItemName | string | 消費したアイテムモデル名 |
| userId | string | ユーザーID |
| consumeCount | long | 消費数量 |


##### 実装例


**Lua**
```lua

-- Request
local namespace = args.namespace
local oldInventory = args.oldInventory
local oldItemSets = args.oldItemSets
local newInventory = args.newInventory
local newItemSets = args.newItemSets
local consumeItemName = args.consumeItemName
local userId = args.userId
local consumeCount = args.consumeCount

-- 非同期スクリプトは通常、API のレスポンスには影響を与えません。
-- ログ出力や分析、外部通知などに使用します。

result = {
}
```


---
  
### simpleItemAcquire

シンプルアイテム入手
**関連するメソッド:**
acquireSimpleItemsByUserId - ユーザーIDを指定してシンプルアイテムを入手


#### 同期実行スクリプト

シンプルアイテム入手処理の前に、スクリプトが同期実行されます。

##### Request

| | 型 | 説明 |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | ネームスペース |
| inventoryName | string | シンプルインベントリモデル名<br>このインベントリのアイテムの種類を定義するシンプルインベントリモデルの名前です。ユーザーのシンプルインベントリインスタンスをモデル定義にリンクします。 |
| simpleItems | [SimpleItem[]](../sdk/#simpleitem) | シンプルアイテムのリスト |
| userId | string | ユーザーID |
| acquireCounts | [AcquireCount[]](../sdk/#acquirecount) | シンプルアイテムの入手数量リスト |

##### Result

|  | 型 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | シンプルアイテム入手を許可するか |
| overrideAcquireCounts | AcquireCount[] |  |  | 0 ~ 100 items | シンプルアイテムの入手数量リスト |

##### 実装例


**Lua**
```lua

-- Request
local namespace = args.namespace
local inventoryName = args.inventoryName
local simpleItems = args.simpleItems
local userId = args.userId
local acquireCounts = args.acquireCounts

-- Business logic:
local permit = true
local overrideAcquireCounts = {}

-- Result
result = {
  permit=permit,
  overrideAcquireCounts=overrideAcquireCounts
}
```


#### 非同期実行スクリプト

シンプルアイテム入手処理の後に、スクリプトが非同期実行されます。

##### Request

| | 型 | 説明 |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | ネームスペース |
| inventoryName | string | シンプルインベントリモデル名<br>このインベントリのアイテムの種類を定義するシンプルインベントリモデルの名前です。ユーザーのシンプルインベントリインスタンスをモデル定義にリンクします。 |
| oldSimpleItems | [SimpleItem[]](../sdk/#simpleitem) | 更新前のシンプルアイテムのリスト |
| newSimpleItems | [SimpleItem[]](../sdk/#simpleitem) | 更新後のシンプルアイテムのリスト |
| userId | string | ユーザーID |
| acquireCounts | [AcquireCount[]](../sdk/#acquirecount) | シンプルアイテムのリスト |


##### 実装例


**Lua**
```lua

-- Request
local namespace = args.namespace
local inventoryName = args.inventoryName
local oldSimpleItems = args.oldSimpleItems
local newSimpleItems = args.newSimpleItems
local userId = args.userId
local acquireCounts = args.acquireCounts

-- 非同期スクリプトは通常、API のレスポンスには影響を与えません。
-- ログ出力や分析、外部通知などに使用します。

result = {
}
```


---
  
### simpleItemConsume

シンプルアイテム消費
**関連するメソッド:**
consumeSimpleItems - シンプルアイテムを消費
consumeSimpleItemsByUserId - ユーザーIDを指定してシンプルアイテムを消費


#### 同期実行スクリプト

シンプルアイテム消費処理の前に、スクリプトが同期実行されます。

##### Request

| | 型 | 説明 |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | ネームスペース |
| inventoryName | string | シンプルインベントリモデル名<br>このインベントリのアイテムの種類を定義するシンプルインベントリモデルの名前です。ユーザーのシンプルインベントリインスタンスをモデル定義にリンクします。 |
| simpleItems | [SimpleItem[]](../sdk/#simpleitem) | シンプルアイテムのリスト |
| userId | string | ユーザーID |
| consumeCounts | [ConsumeCount[]](../sdk/#consumecount) | シンプルアイテムの消費数量のリスト |

##### Result

|  | 型 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | シンプルアイテム消費を許可するか |
| overrideConsumeCounts | ConsumeCount[] |  |  | 0 ~ 100 items | シンプルアイテムのリスト |

##### 実装例


**Lua**
```lua

-- Request
local namespace = args.namespace
local inventoryName = args.inventoryName
local simpleItems = args.simpleItems
local userId = args.userId
local consumeCounts = args.consumeCounts

-- Business logic:
local permit = true
local overrideConsumeCounts = {}

-- Result
result = {
  permit=permit,
  overrideConsumeCounts=overrideConsumeCounts
}
```


#### 非同期実行スクリプト

シンプルアイテム消費処理の後に、スクリプトが非同期実行されます。

##### Request

| | 型 | 説明 |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | ネームスペース |
| inventoryName | string | シンプルインベントリモデル名<br>このインベントリのアイテムの種類を定義するシンプルインベントリモデルの名前です。ユーザーのシンプルインベントリインスタンスをモデル定義にリンクします。 |
| oldSimpleItems | [SimpleItem[]](../sdk/#simpleitem) | 更新前のシンプルアイテムのリスト |
| newSimpleItems | [SimpleItem[]](../sdk/#simpleitem) | 更新後のシンプルアイテムのリスト |
| userId | string | ユーザーID |
| consumeCounts | [ConsumeCount[]](../sdk/#consumecount) | シンプルアイテムの消費数量リスト |


##### 実装例


**Lua**
```lua

-- Request
local namespace = args.namespace
local inventoryName = args.inventoryName
local oldSimpleItems = args.oldSimpleItems
local newSimpleItems = args.newSimpleItems
local userId = args.userId
local consumeCounts = args.consumeCounts

-- 非同期スクリプトは通常、API のレスポンスには影響を与えません。
-- ログ出力や分析、外部通知などに使用します。

result = {
}
```


---
  
### bigItemAcquire

巨大アイテム入手
**関連するメソッド:**
acquireBigItemByUserId - ユーザーIDを指定して巨大アイテムを入手


#### 同期実行スクリプト

巨大アイテム入手処理の前に、スクリプトが同期実行されます。

##### Request

| | 型 | 説明 |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | ネームスペース |
| inventoryName | string | 巨大インベントリモデル名<br>このインベントリのアイテムの種類を定義する巨大インベントリモデルの名前です。ユーザーの巨大インベントリインスタンスをモデル定義にリンクします。 |
| itemName | string | 巨大アイテムモデル名<br>このレコードに格納されているアイテムの種類を定義する巨大アイテムモデルの名前です。この巨大アイテムの所持品がどのアイテム定義に対応するかを識別するために使用されます。 |
| item | [BigItem](../sdk/#bigitem) | 巨大アイテム |
| userId | string | ユーザーID |
| acquireCount | string | 巨大アイテムの入手数量<br>最大1024桁までの整数値文字列 |

##### Result

|  | 型 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | 巨大アイテム入手を許可するか |
| rate | float |  | 1.0 | 0 ~ 1000 | 入手量の倍率 |

##### 実装例


**Lua**
```lua

-- Request
local namespace = args.namespace
local inventoryName = args.inventoryName
local itemName = args.itemName
local item = args.item
local userId = args.userId
local acquireCount = args.acquireCount

-- Business logic:
local permit = true
local rate = 1.0

-- Result
result = {
  permit=permit,
  rate=rate
}
```


#### 非同期実行スクリプト

巨大アイテム入手処理の後に、スクリプトが非同期実行されます。

##### Request

| | 型 | 説明 |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | ネームスペース |
| inventoryName | string | 巨大インベントリモデル名<br>このインベントリのアイテムの種類を定義する巨大インベントリモデルの名前です。ユーザーの巨大インベントリインスタンスをモデル定義にリンクします。 |
| itemName | string | 巨大アイテムモデル名<br>このレコードに格納されているアイテムの種類を定義する巨大アイテムモデルの名前です。この巨大アイテムの所持品がどのアイテム定義に対応するかを識別するために使用されます。 |
| oldItem | [BigItem](../sdk/#bigitem) | 更新前の巨大アイテム |
| newItem | [BigItem](../sdk/#bigitem) | 更新後の巨大アイテム |
| userId | string | ユーザーID |
| acquireCount | string | 巨大アイテムの入手数量<br>最大1024桁までの整数値文字列 |


##### 実装例


**Lua**
```lua

-- Request
local namespace = args.namespace
local inventoryName = args.inventoryName
local itemName = args.itemName
local oldItem = args.oldItem
local newItem = args.newItem
local userId = args.userId
local acquireCount = args.acquireCount

-- 非同期スクリプトは通常、API のレスポンスには影響を与えません。
-- ログ出力や分析、外部通知などに使用します。

result = {
}
```


---
  
### bigItemConsume

巨大アイテム消費
**関連するメソッド:**
consumeBigItem - 巨大アイテムを消費
consumeBigItemByUserId - ユーザーIDを指定して巨大アイテムを消費


#### 同期実行スクリプト

巨大アイテム消費処理の前に、スクリプトが同期実行されます。

##### Request

| | 型 | 説明 |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | ネームスペース |
| inventoryName | string | 巨大インベントリモデル名<br>このインベントリのアイテムの種類を定義する巨大インベントリモデルの名前です。ユーザーの巨大インベントリインスタンスをモデル定義にリンクします。 |
| itemName | string | 巨大アイテムモデル名<br>このレコードに格納されているアイテムの種類を定義する巨大アイテムモデルの名前です。この巨大アイテムの所持品がどのアイテム定義に対応するかを識別するために使用されます。 |
| item | [BigItem](../sdk/#bigitem) | 巨大アイテム |
| userId | string | ユーザーID |
| consumeCount | string | 巨大アイテムの消費数量<br>最大1024桁までの整数値文字列 |

##### Result

|  | 型 | 必須 | デフォルト | 値の制限 | 説明 |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | 巨大アイテム消費を許可するか |
| rate | float |  | 1.0 | 0 ~ 1000 | 消費量の倍率 |

##### 実装例


**Lua**
```lua

-- Request
local namespace = args.namespace
local inventoryName = args.inventoryName
local itemName = args.itemName
local item = args.item
local userId = args.userId
local consumeCount = args.consumeCount

-- Business logic:
local permit = true
local rate = 1.0

-- Result
result = {
  permit=permit,
  rate=rate
}
```


#### 非同期実行スクリプト

巨大アイテム消費処理の後に、スクリプトが非同期実行されます。

##### Request

| | 型 | 説明 |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | ネームスペース |
| inventoryName | string | 巨大インベントリモデル名<br>このインベントリのアイテムの種類を定義する巨大インベントリモデルの名前です。ユーザーの巨大インベントリインスタンスをモデル定義にリンクします。 |
| itemName | string | 巨大アイテムモデル名<br>このレコードに格納されているアイテムの種類を定義する巨大アイテムモデルの名前です。この巨大アイテムの所持品がどのアイテム定義に対応するかを識別するために使用されます。 |
| oldItem | [BigItem](../sdk/#bigitem) | 更新前の巨大アイテム |
| newItem | [BigItem](../sdk/#bigitem) | 更新後の巨大アイテム |
| userId | string | ユーザーID |
| consumeCount | string | 巨大アイテムの消費数量<br>最大1024桁までの整数値文字列 |


##### 実装例


**Lua**
```lua

-- Request
local namespace = args.namespace
local inventoryName = args.inventoryName
local itemName = args.itemName
local oldItem = args.oldItem
local newItem = args.newItem
local userId = args.userId
local consumeCount = args.consumeCount

-- 非同期スクリプトは通常、API のレスポンスには影響を与えません。
-- ログ出力や分析、外部通知などに使用します。

result = {
}
```


---
  



