GS2-Limit Script Trigger Reference

Reference for event triggers that call extended scripts

Trigger

countUp

Count up

Synchronous Execution Script

The script is executed synchronously before the count up process.

Request
Type Description
namespace Namespace Namespace
limitModel LimitModel Usage Limit Model
counter Counter Counter
userId string User ID
countUpValue int Amount to count up
maxValue int Maximum value allowed to count up
Result
Type Required Default Value Limits Description
permit bool
Whether to allow count up
Implementation Example
-- Request
local namespace = args.namespace
local limitModel = args.limitModel
local counter = args.counter
local userId = args.userId
local countUpValue = args.countUpValue
local maxValue = args.maxValue

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}

Asynchronous Execution Script

The script is executed asynchronously after the count up process.

Request
Type Description
namespace Namespace Namespace
limitModel LimitModel Usage Limit Model
oldCounter Counter Counter before update
newCounter Counter Counter after update
userId string User ID
countUpValue int Amount to count up
maxValue int Maximum value allowed to count up
Implementation Example
-- Request
local namespace = args.namespace
local limitModel = args.limitModel
local oldCounter = args.oldCounter
local newCounter = args.newCounter
local userId = args.userId
local countUpValue = args.countUpValue
local maxValue = args.maxValue

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

result = {
}