Trigger Reference of GS2-Inventory Script

acquire

Event trigger to call GS2-Script before an 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 an 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 an 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 an 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 = {
}