Trigger Reference of GS2-Inventory Script

acquire

Event trigger to call GS2-Script before Item is acquired.

Request

TypeDescription
namespaceNamespaceNamespace
inventoryInventoryInventory
itemSetsItemSet[]List of Quantity of items held per expiration date
acquireItemNamestringName of item model acquired
userIdstringUser Id
acquireCountlongQuantity acquired
expiresAtlongEffective date

Result

TypeRequireDefaultLimitationDescription
permitboolAllow item acquisition
overrideAcquireCountint~ 2147483645Actual amount obtained to be applied

Implementation Example

namespace = args.namespace
inventory = args.inventory
itemSets = args.itemSets
acquireItemName = args.acquireItemName
userId = args.userId
acquireCount = args.acquireCount
expiresAt = args.expiresAt

result = {
  permit=permit,
  overrideAcquireCount=overrideAcquireCount
}

acquireDone

GS2-Script called after Item is acquired.

Request

TypeDescription
namespaceNamespaceNamespace
oldInventoryInventoryInventory before update
oldItemSetsItemSet[]List of Quantity of items held per expiration date before renewal
newInventoryInventoryInventory after update
newItemSetsItemSet[]List of Quantity of items held per renewal expiration date
acquireItemNamestringName of item model acquired
userIdstringUser Id
acquireCountlongQuantity acquired
overflowValuelongAmount of overflow
expiresAtlongEffective date

Result

TypeRequireDefaultLimitationDescription

Implementation Example

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

result = {
}

overflowDone

Event trigger to call GS2-Script when the number of items hits the acquisition limit and notification of the quantity not obtained is completed.

Request

TypeDescription
namespaceNamespaceNamespace
inventoryInventoryInventory
itemModelItemModelItem Model
userIdstringUser Id
overflowValuelongAmount of overflow

Result

TypeRequireDefaultLimitationDescription

Implementation Example

namespace = args.namespace
inventory = args.inventory
itemModel = args.itemModel
userId = args.userId
overflowValue = args.overflowValue

result = {
}

consume

Event trigger to call GS2-Script before Item is consumed.

Request

TypeDescription
namespaceNamespaceNamespace
inventoryInventoryInventory
itemSetsItemSet[]List of Quantity of items held per expiration date
consumeItemNamestringName of item model consumed
userIdstringUser Id
consumeCountlongQuantity consumed

Result

TypeRequireDefaultLimitationDescription
permitboolAllow item consumption
overrideConsumeCountint~ 2147483645Actual consumption to be applied

Implementation Example

namespace = args.namespace
inventory = args.inventory
itemSets = args.itemSets
consumeItemName = args.consumeItemName
userId = args.userId
consumeCount = args.consumeCount

result = {
  permit=permit,
  overrideConsumeCount=overrideConsumeCount
}

consumeDone

GS2-Script called after Item is consumed.

Request

TypeDescription
namespaceNamespaceNamespace
oldInventoryInventoryInventory before consumption
oldItemSetsItemSet[]List of Quantity of items held per expiration date before consumption
newInventoryInventoryInventory after consumption
newItemSetsItemSet[]List of Quantity of items held per post-consumption expiration date
consumeItemNamestringName of item model consumed
userIdstringUser Id
consumeCountlongQuantity consumed

Result

TypeRequireDefaultLimitationDescription

Implementation Example

namespace = args.namespace
oldInventory = args.oldInventory
oldItemSets = args.oldItemSets
newInventory = args.newInventory
newItemSets = args.newItemSets
consumeItemName = args.consumeItemName
userId = args.userId
consumeCount = args.consumeCount

result = {
}

simpleItemAcquire

Event trigger to call GS2-Script before Simple item is acquired.

Request

TypeDescription
namespaceNamespaceNamespace
inventoryNamestringSimple Inventory Model Name
simpleItemsSimpleItem[]List of Quantity of items held per expiration date
userIdstringUser Id
acquireCountsAcquireCount[]List of quantity of items to be obtained

Result

TypeRequireDefaultLimitationDescription
permitboolAllow item acquisition
overrideAcquireCountsAcquireCount[]~ 100 itemsList of quantity of items to be obtained

Implementation Example

namespace = args.namespace
inventoryName = args.inventoryName
simpleItems = args.simpleItems
userId = args.userId
acquireCounts = args.acquireCounts

result = {
  permit=permit,
  overrideAcquireCounts=overrideAcquireCounts
}

simpleItemAcquireDone

GS2-Script called after Simple item is acquired.

Request

TypeDescription
namespaceNamespaceNamespace
inventoryNamestringSimple Inventory Model Name
oldSimpleItemsSimpleItem[]List of Quantity of items held per expiration date
newSimpleItemsSimpleItem[]List of Quantity of items held per expiration date
userIdstringUser Id
acquireCountsAcquireCount[]List of quantity of items to be obtained

Result

TypeRequireDefaultLimitationDescription

Implementation Example

namespace = args.namespace
inventoryName = args.inventoryName
oldSimpleItems = args.oldSimpleItems
newSimpleItems = args.newSimpleItems
userId = args.userId
acquireCounts = args.acquireCounts

result = {
}

simpleItemConsume

Event trigger to call GS2-Script before Simple item is consumed.

Request

TypeDescription
namespaceNamespaceNamespace
inventoryNamestringSimple Inventory Model Name
simpleItemsSimpleItem[]List of Simple Item
userIdstringUser Id
consumeCountsConsumeCount[]List of quantity of items to be consumed

Result

TypeRequireDefaultLimitationDescription
permitboolAllow item consumption
overrideConsumeCountsConsumeCount[]~ 100 itemsList of quantity of items to be consumed

Implementation Example

namespace = args.namespace
inventoryName = args.inventoryName
simpleItems = args.simpleItems
userId = args.userId
consumeCounts = args.consumeCounts

result = {
  permit=permit,
  overrideConsumeCounts=overrideConsumeCounts
}

simpleItemConsumeDone

GS2-Script called after Simple item is consumed.

Request

TypeDescription
namespaceNamespaceNamespace
inventoryNamestringSimple Inventory Model Name
oldSimpleItemsSimpleItem[]List of Before update Simple Item
newSimpleItemsSimpleItem[]List of After update Simple Item
userIdstringUser Id
consumeCountsConsumeCount[]List of quantity of items to be consumed

Result

TypeRequireDefaultLimitationDescription

Implementation Example

namespace = args.namespace
inventoryName = args.inventoryName
oldSimpleItems = args.oldSimpleItems
newSimpleItems = args.newSimpleItems
userId = args.userId
consumeCounts = args.consumeCounts

result = {
}

bigItemAcquire

Event trigger to call GS2-Script before Big item is consumed.

Request

TypeDescription
namespaceNamespaceNamespace
inventoryNamestringBig Inventory Model Name
itemNamestringBig Item Model Name
itemBigItemSimple Item
userIdstringUser Id
acquireCountstringList of quantity of items to be obtained

Result

TypeRequireDefaultLimitationDescription
permitboolAllow item acquisition
ratefloat1.0~ 1000Acquisition quantity rate

Implementation Example

namespace = args.namespace
inventoryName = args.inventoryName
itemName = args.itemName
item = args.item
userId = args.userId
acquireCount = args.acquireCount

result = {
  permit=permit,
  rate=rate
}

bigItemAcquireDone

GS2-Script called after Big item is consumed.

Request

TypeDescription
namespaceNamespaceNamespace
inventoryNamestringBig Inventory Model Name
itemNamestringBig Item Model Name
oldItemBigItemBefore update Simple Item
newItemBigItemAfter update Simple Item
userIdstringUser Id
acquireCountstringList of quantity of items to be obtained

Result

TypeRequireDefaultLimitationDescription

Implementation Example

namespace = args.namespace
inventoryName = args.inventoryName
itemName = args.itemName
oldItem = args.oldItem
newItem = args.newItem
userId = args.userId
acquireCount = args.acquireCount

result = {
}

bigItemConsume

Event trigger to call GS2-Script before Big item is consumed.

Request

TypeDescription
namespaceNamespaceNamespace
inventoryNamestringBig Inventory Model Name
itemNamestringBig Item Model Name
itemBigItemSimple Item
userIdstringUser Id
consumeCountstringList of quantity of items to be consumed

Result

TypeRequireDefaultLimitationDescription
permitboolAllow item consumption
ratefloat1.0~ 1000Consume quantity rate

Implementation Example

namespace = args.namespace
inventoryName = args.inventoryName
itemName = args.itemName
item = args.item
userId = args.userId
consumeCount = args.consumeCount

result = {
  permit=permit,
  rate=rate
}

bigItemConsumeDone

GS2-Script called after Big item is consumed.

Request

TypeDescription
namespaceNamespaceNamespace
inventoryNamestringBig Inventory Model Name
itemNamestringBig Item Model Name
oldItemBigItemBefore update Simple Item
newItemBigItemAfter update Simple Item
userIdstringUser Id
consumeCountstringList of quantity of items to be consumed

Result

TypeRequireDefaultLimitationDescription

Implementation Example

namespace = args.namespace
inventoryName = args.inventoryName
itemName = args.itemName
oldItem = args.oldItem
newItem = args.newItem
userId = args.userId
consumeCount = args.consumeCount

result = {
}