> For the complete documentation index, see [llms.txt](https://arcplay-ai.gitbook.io/knowledge-portal/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://arcplay-ai.gitbook.io/knowledge-portal/for-h5-games/integration-steps/game-to-web-events-firing.md).

# Game to Web Events Firing

To send events from the game to ArcPlay, a message will need to be posted to the parent of the iframe in which the game is running. An example of this would be:

```javascript
// Sent when user started the game
parent.postMessage({funcName: "game_start_success"}, "*");
// Sent when the web needs to show a rewarded video ad
parent.postMessage({funcName: "game_reward_click", rewardParams: { itemId: 1 }}, "*");
```

The data will be in the format `{ funcName: “string”, …other data }` where `funcName` is the name of the event and any other data is sent as additional parameters. It can be one of the following.

| Event Name           | Firing Logic                                                                                                                                                                                                                                                                                                        |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `game_init`          | When the game has started to load                                                                                                                                                                                                                                                                                   |
| `game_update_load`   | <p>Call this function every time there is an increase in the loading percentage of the game.<br><br>MUST contain the loading percentage with the key name <code>loadStatus</code> as an additional parameter. The value of <code>loadStatus</code> should be an <code>integer</code> </p>                           |
| `game_load_success`  | When all the game assets are done loading. Usually on the start menu                                                                                                                                                                                                                                                |
| `game_start_success` | When the game starts. Usually after the user clicks on “Play” or a similar button in the start menu                                                                                                                                                                                                                 |
| `game_update_score`  | <p>Call this function every time there is a score update inside the game.<br><br>MUST contain the updated score with the key name <code>liveScore</code> as an additional parameter. The value of <code>liveScore</code> should be an <code>double</code></p>                                                       |
| `game_reward_click`  | <p>When the user clicks on a button to watch a rewarded video ad to unlock an item in the game<br><br>MUST contain the reward parameters with the key name <code>rewardParams</code> as an additional parameter. The value of <code>rewardParams</code> will be sent back to the game from the web later.</p>       |
| `game_paused`        | <p>When the game has been paused. <br><br>DON'T send this if the pause was triggered by listening to ArcPlay <code>game\_pause</code> event</p>                                                                                                                                                                     |
| `game_resumed`       | When the game has resumed                                                                                                                                                                                                                                                                                           |
| `game_over`          | <p>When the game is over, regardless of whether the user has won.<br><br>MUST contain the final score with the key name <code>score</code> as an additional parameter. The value of <code>score</code> should be an <code>double</code> </p>                                                                        |
| `game_fatal_error`   | <p>When the user is unable to move ahead in the game flow due to a technical issue on the game side.<br><br>MUST contain the reason for error with the key name <code>code</code> and <code>message</code> . The value type for <code>code</code> should be 'int' and <code>message</code> should be  'string'.</p> |
