GS2-Inventory Script Trigger Reference

Reference of event triggers that call extended scripts

Trigger

acquire

Item acquisition

Synchronous Execution Script

The script is executed synchronously before the item acquisition process.

Request
TypeDescription
namespaceNamespaceNamespace
inventoryInventoryInventory
itemSetsItemSet[]List of Item Sets
acquireItemNamestringName of Item Model acquired
userIdstringUser ID
acquireCountlongQuantity acquired
expiresAtlongExpiration time
Unix time, milliseconds
Result
TypeRequiredDefaultValue LimitsDescription
permitbool
Whether to allow item acquisition
overrideAcquireCountint0 ~ 2147483645Actual amount obtained to be applied
Implementation Example
-- 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
}

Asynchronous Execution Script

The script is executed asynchronously after the item acquisition process.

Request
TypeDescription
namespaceNamespaceNamespace
oldInventoryInventoryInventory before update
oldItemSetsItemSet[]List of Item Sets before renewal
newInventoryInventoryInventory after update
newItemSetsItemSet[]List of updated Item Sets
acquireItemNamestringName of Item Model acquired
userIdstringUser ID
acquireCountlongQuantity acquired
overflowValuelongAmount of overflow
expiresAtlongExpiration time
Unix time, milliseconds
Implementation Example
-- 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

-- Asynchronous scripts typically do not affect the API response.
-- Use for logging, analytics, external notifications, etc.

result = {
}

overflowDone

the number of items hits the acquisition limit and notification of the quantity not obtained is completed

Synchronous Execution Script

The script is executed synchronously before the the number of items hits the acquisition limit and notification of the quantity not obtained is completed process.

Request
TypeDescription
namespaceNamespaceNamespace
inventoryInventoryInventory
itemModelItemModelItem Model
userIdstringUser ID
overflowValuelongAmount of overflow
Implementation Example
-- 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

item consumption

Synchronous Execution Script

The script is executed synchronously before the item consumption process.

Request
TypeDescription
namespaceNamespaceNamespace
inventoryInventoryInventory
itemSetsItemSet[]List of Item Sets
consumeItemNamestringName of Item Model consumed
userIdstringUser ID
consumeCountlongQuantity consumed
Result
TypeRequiredDefaultValue LimitsDescription
permitbool
Whether to allow item consumption
overrideConsumeCountint0 ~ 2147483645Actual consumption to be applied
Implementation Example
-- 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
}

Asynchronous Execution Script

The script is executed asynchronously after the item consumption process.

Request
TypeDescription
namespaceNamespaceNamespace
oldInventoryInventoryInventory before consumption
oldItemSetsItemSet[]List of Item Sets before consumption
newInventoryInventoryInventory after consumption
newItemSetsItemSet[]List of Item Sets after consumption
consumeItemNamestringName of Item Model consumed
userIdstringUser ID
consumeCountlongQuantity consumed
Implementation Example
-- 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

-- Asynchronous scripts typically do not affect the API response.
-- Use for logging, analytics, external notifications, etc.

result = {
}

simpleItemAcquire

Simple Item acquisition

Synchronous Execution Script

The script is executed synchronously before the simple item acquisition process.

Request
TypeDescription
namespaceNamespaceNamespace
inventoryNamestringSimple Inventory Model Name
The name of the simple inventory model that defines the item types for this inventory. Links the user’s simple inventory instance to its model definition.
simpleItemsSimpleItem[]List of Simple Items
userIdstringUser ID
acquireCountsAcquireCount[]List of acquisition quantities for Simple Items
Result
TypeRequiredDefaultValue LimitsDescription
permitbool
Whether to allow Simple Item acquisition
overrideAcquireCountsAcquireCount[]0 ~ 100 itemsList of acquisition quantities for Simple Items
Implementation Example
-- 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
}

Asynchronous Execution Script

The script is executed asynchronously after the simple item acquisition process.

Request
TypeDescription
namespaceNamespaceNamespace
inventoryNamestringSimple Inventory Model Name
The name of the simple inventory model that defines the item types for this inventory. Links the user’s simple inventory instance to its model definition.
oldSimpleItemsSimpleItem[]List of Simple Items before update
newSimpleItemsSimpleItem[]List of Simple Items after Update
userIdstringUser ID
acquireCountsAcquireCount[]List of Simple Items
Implementation Example
-- 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

-- Asynchronous scripts typically do not affect the API response.
-- Use for logging, analytics, external notifications, etc.

result = {
}

simpleItemConsume

Simple Item consumption

Synchronous Execution Script

The script is executed synchronously before the simple item consumption process.

Request
TypeDescription
namespaceNamespaceNamespace
inventoryNamestringSimple Inventory Model Name
The name of the simple inventory model that defines the item types for this inventory. Links the user’s simple inventory instance to its model definition.
simpleItemsSimpleItem[]List of Simple Item
userIdstringUser ID
consumeCountsConsumeCount[]List of consumption quantities of Simple Items
Result
TypeRequiredDefaultValue LimitsDescription
permitbool
Whether to allow Simple Item consumption
overrideConsumeCountsConsumeCount[]0 ~ 100 itemsList of Simple Items
Implementation Example
-- 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
}

Asynchronous Execution Script

The script is executed asynchronously after the simple item consumption process.

Request
TypeDescription
namespaceNamespaceNamespace
inventoryNamestringSimple Inventory Model Name
The name of the simple inventory model that defines the item types for this inventory. Links the user’s simple inventory instance to its model definition.
oldSimpleItemsSimpleItem[]List of Before update Simple Items
newSimpleItemsSimpleItem[]List of After update Simple Items
userIdstringUser ID
consumeCountsConsumeCount[]List of consumption quantities of Simple Items
Implementation Example
-- 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

-- Asynchronous scripts typically do not affect the API response.
-- Use for logging, analytics, external notifications, etc.

result = {
}

bigItemAcquire

Big Item acquisition

Synchronous Execution Script

The script is executed synchronously before the big item acquisition process.

Request
TypeDescription
namespaceNamespaceNamespace
inventoryNamestringBig Inventory Model Name
The name of the big inventory model that defines the item types for this inventory. Links the user’s big inventory instance to its model definition.
itemNamestringBig Item Model Name
The name of the big item model that defines the type of item stored in this record. Used to identify which item definition this big item possession corresponds to.
itemBigItemBig Item
userIdstringUser ID
acquireCountstringAcquisition quantity for a Big Item
Integer value strings up to 1024 digits
Result
TypeRequiredDefaultValue LimitsDescription
permitbool
Whether to allow Big Item acquisition
ratefloat1.00 ~ 1000Acquisition quantity rate
Implementation Example
-- 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 = 0

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

Asynchronous Execution Script

The script is executed asynchronously after the big item acquisition process.

Request
TypeDescription
namespaceNamespaceNamespace
inventoryNamestringBig Inventory Model Name
The name of the big inventory model that defines the item types for this inventory. Links the user’s big inventory instance to its model definition.
itemNamestringBig Item Model Name
The name of the big item model that defines the type of item stored in this record. Used to identify which item definition this big item possession corresponds to.
oldItemBigItemBefore update Big Item
newItemBigItemAfter update Big Item
userIdstringUser ID
acquireCountstringAcquisition quantity for a Big Item
Integer value strings up to 1024 digits
Implementation Example
-- 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

-- Asynchronous scripts typically do not affect the API response.
-- Use for logging, analytics, external notifications, etc.

result = {
}

bigItemConsume

big item consumption

Synchronous Execution Script

The script is executed synchronously before the big item consumption process.

Request
TypeDescription
namespaceNamespaceNamespace
inventoryNamestringBig Inventory Model Name
The name of the big inventory model that defines the item types for this inventory. Links the user’s big inventory instance to its model definition.
itemNamestringBig Item Model Name
The name of the big item model that defines the type of item stored in this record. Used to identify which item definition this big item possession corresponds to.
itemBigItemBig Item
userIdstringUser ID
consumeCountstringConsumption quantity of a Big Item
Integer value strings up to 1024 digits
Result
TypeRequiredDefaultValue LimitsDescription
permitbool
Whether to allow Big Item consumption
ratefloat1.00 ~ 1000Consume quantity rate
Implementation Example
-- 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 = 0

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

Asynchronous Execution Script

The script is executed asynchronously after the big item consumption process.

Request
TypeDescription
namespaceNamespaceNamespace
inventoryNamestringBig Inventory Model Name
The name of the big inventory model that defines the item types for this inventory. Links the user’s big inventory instance to its model definition.
itemNamestringBig Item Model Name
The name of the big item model that defines the type of item stored in this record. Used to identify which item definition this big item possession corresponds to.
oldItemBigItemBefore update Big Item
newItemBigItemAfter update Big Item
userIdstringUser ID
consumeCountstringConsumption quantity of a Big Item
Integer value strings up to 1024 digits
Implementation Example
-- 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

-- Asynchronous scripts typically do not affect the API response.
-- Use for logging, analytics, external notifications, etc.

result = {
}