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

# GS2-Grade Script Trigger Reference

Reference for event triggers that call extended scripts



## Trigger

### changeGrade

grade changes

**Related methods:**
addGradeByUserId - Add grade by User ID
subGrade - Subtract grade
subGradeByUserId - Subtract grade by User ID
setGradeByUserId - Set cumulative grade gained


#### Synchronous Execution Script

The script is executed synchronously before the grade changes process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| gradeModel | [GradeModel](../sdk/#grademodel) | Grade 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 grade changes |
| overrideGradeValue | long | ✓ |  | 0 ~ 2147483645 | Overriding grade value |

##### Implementation Example


**Lua**
```lua

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

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

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


#### Asynchronous Execution Script

The script is executed asynchronously after the grade changes process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| gradeModel | [GradeModel](../sdk/#grademodel) | Grade Model |
| status | [Status](../sdk/#status) | Status |
| afterStatus | [Status](../sdk/#status) | Status after change |


##### Implementation Example


**Lua**
```lua

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

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

result = {
}
```


---
  



