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

# GS2-Experience Script Trigger Reference

Reference for event triggers that call extended scripts



## Trigger

### rankCapScript

Rank cap acquisition


#### Synchronous Execution Script

The script is executed synchronously before the rank cap acquisition process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| experienceModel | [ExperienceModel](../sdk/#experiencemodel) | Experience Model |
| userId | string | User ID |
| propertyId | string | Property ID<br>A developer-defined identifier that uniquely identifies this status within the user's scope. It is recommended to use a value that appends an experience model suffix to the GS2-Inventory Item Set GRN or GS2-Dictionary Entry GRN that possesses the experience. |

##### Result

|  | Type | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- |
| rankCap | long | ✓ |  | 0 ~ 2147483645 | Rank Cap |

##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local experienceModel = args.experienceModel
local userId = args.userId
local propertyId = args.propertyId

-- Business logic:
local rankCap = 0

-- Result
result = {
  rankCap=rankCap
}
```


---
  
### changeExperience

experience value changes

**Related methods:**
addExperienceByUserId - Add experience by User ID
subExperience - Subtract experience
subExperienceByUserId - Subtract experience by User ID
setExperienceByUserId - Set experience by User ID


#### Synchronous Execution Script

The script is executed synchronously before the experience value changes process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| experienceModel | [ExperienceModel](../sdk/#experiencemodel) | Experience Model |
| status | [Status](../sdk/#status) | Status before change |
| afterStatus | [Status](../sdk/#status) | Status after change |

##### Result

|  | Type | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | Whether to allow experience value changes |
| overrideExperienceValue | long | ✓ |  | 0 ~ 2147483645 | Overriding experience value |

##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local experienceModel = args.experienceModel
local status = args.status
local afterStatus = args.afterStatus

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

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


#### Asynchronous Execution Script

The script is executed asynchronously after the experience value changes process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| experienceModel | [ExperienceModel](../sdk/#experiencemodel) | Experience Model |
| oldStatus | [Status](../sdk/#status) | Status before change |
| status | [Status](../sdk/#status) | Status |


##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local experienceModel = args.experienceModel
local oldStatus = args.oldStatus
local status = args.status

-- Asynchronous scripts typically do not affect the API response.
-- These scripts are typically used for logging, analytics, external notifications, and similar purposes.

result = {
}
```


---
  
### changeRank

Rank changes

**Related methods:**
addExperienceByUserId - Add experience by User ID
subExperience - Subtract experience
subExperienceByUserId - Subtract experience by User ID


#### Synchronous Execution Script

The script is executed synchronously before the rank changes process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| experienceModel | [ExperienceModel](../sdk/#experiencemodel) | Experience Model |
| status | [Status](../sdk/#status) | Status before change |
| afterStatus | [Status](../sdk/#status) | Status after change |

##### Result

|  | Type | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | Whether to allow rank changes |

##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local experienceModel = args.experienceModel
local status = args.status
local afterStatus = args.afterStatus

-- Business logic:
local permit = true

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


#### Asynchronous Execution Script

The script is executed asynchronously after the rank changes process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| experienceModel | [ExperienceModel](../sdk/#experiencemodel) | Experience Model |
| oldStatus | [Status](../sdk/#status) | Status before change |
| status | [Status](../sdk/#status) | Status |


##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local experienceModel = args.experienceModel
local oldStatus = args.oldStatus
local status = args.status

-- Asynchronous scripts typically do not affect the API response.
-- These scripts are typically used for logging, analytics, external notifications, and similar purposes.

result = {
}
```


---
  
### changeRankCap

Rank cap changes

**Related methods:**
addRankCapByUserId - Add rank cap by User ID
setRankCapByUserId - Set rank cap by User ID


#### Synchronous Execution Script

The script is executed synchronously before the rank cap changes process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| experienceModel | [ExperienceModel](../sdk/#experiencemodel) | Experience Model |
| status | [Status](../sdk/#status) | Status before change |
| afterStatus | [Status](../sdk/#status) | Status after change |

##### Result

|  | Type | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | Whether to allow rank cap change |
| overrideRankCapValue | long | ✓ |  | 0 ~ 2147483645 | New rank cap |

##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local experienceModel = args.experienceModel
local status = args.status
local afterStatus = args.afterStatus

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

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


#### Asynchronous Execution Script

The script is executed asynchronously after the rank cap changes process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| experienceModel | [ExperienceModel](../sdk/#experiencemodel) | Experience Model |
| status | [Status](../sdk/#status) | Status |


##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local experienceModel = args.experienceModel
local status = args.status

-- Asynchronous scripts typically do not affect the API response.
-- These scripts are typically used for logging, analytics, external notifications, and similar purposes.

result = {
}
```


---
  
### overflowExperience

Experience overflow

**Related methods:**
addExperienceByUserId - Add experience by User ID
subExperience - Subtract experience
subExperienceByUserId - Subtract experience by User ID
setExperienceByUserId - Set experience by User ID
addRankCapByUserId - Add rank cap by User ID
setRankCapByUserId - Set rank cap by User ID


#### Synchronous Execution Script

The script is executed synchronously before the experience overflow process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| experienceModel | [ExperienceModel](../sdk/#experiencemodel) | Experience Model |
| status | [Status](../sdk/#status) | Status |
| overflowExperienceValue | long | Experience overflow value |

##### Result

|  | Type | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | Whether to allow experience overflow |

##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local experienceModel = args.experienceModel
local status = args.status
local overflowExperienceValue = args.overflowExperienceValue

-- Business logic:
local permit = true

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


---
  



