> For the complete documentation index, see [llms.txt](https://zarzel.gitbook.io/zarscript2/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zarzel.gitbook.io/zarscript2/documentation/module/events.md).

# Events

### on\_send\_packet

This event will be called before a packet gets sent to the server.

| Key        | Type    | Description                                  |
| ---------- | ------- | -------------------------------------------- |
| packet\_id | Number  | ID of the packet that is being sent          |
| cancel     | Boolean | If the packet should be stopped from sending |

This event will also return extra keys in the table depending on the packet.\
Changing this table values and returning the table means they will be applied

### on\_receive\_packet

This event will be called before a packet gets processed in the client.

| Key        | Type   | Description                         |
| ---------- | ------ | ----------------------------------- |
| packet\_id | Number | ID of the packet that is being sent |

This event will also return extra keys in the table depending on the packet.

### on\_pre\_update

This event will be called before the local player gets updated

### on\_post\_update

This event will be called after the local player gets updated

### on\_player\_move

This event will be called before the local player movements get processed

| Key | Type   | Description            |
| --- | ------ | ---------------------- |
| x   | Number | Motion X of the player |
| y   | Number | Motion Y of the player |
| z   | Number | Motion Z of the player |

Changing this table values and returning the table means they will be applied

Example:

```lua
on_player_move = function(ctx)
   return player.convert_speed(ctx, 2)
end
```

### on\_player\_join

This event will be called when the local player is created in the world

### on\_pre\_motion

This event will be called before the game sends the position/look packets to the server

| Key        | Type    | Description              |
| ---------- | ------- | ------------------------ |
| x          | Number  | Pos x of the player      |
| y          | Number  | Pos y of the player      |
| z          | Number  | Pos z of the player      |
| yaw        | Number  | Yaw of the player        |
| pitch      | Number  | Pitch of the player      |
| on\_ground | Boolean | Player's on ground state |

Changing this table values and returning the table means they will be applied

Example:

```lua
on_pre_motion = function(ctx)
   ctx.pitch = -180
   return ctx
end
```

### on\_post\_motion

This event will be called after the game sends the position/look packets to the server

### on\_pre\_player\_input

This event will be called before the game processes player inputs, basically before moving depending on your yaw, pitch, forward amount and strafe amount

| Key     | Number | Pos x of the player |
| ------- | ------ | ------------------- |
| strafe  | Number | Strafe amount       |
| forward | Number | Forward amount      |

Changing this table values and returning the table means they will be applied

Changing yaw and pitch on the player on this event, and changing it back to the previous ones in `on_post_player_input`will change the movement as you were looking where you setted the angles in this event.

### on\_post\_player\_input

This event will be called after the game processes player inputs.

### on\_render\_world

This event will be called when the game is rendering the screen

### on\_render\_screen

This event will be called when the game is rendering the HUD

| Key            | Type   | Description                                   |
| -------------- | ------ | --------------------------------------------- |
| partial\_ticks | Number | How much time has elapsed since the last tick |
| width          | Number | Width of the Minecraft window                 |
| height         | Number | Height of the Minecraft Window                |
| scale\_factor  | Number | GUI Scaling                                   |
| mouse\_x       | Number | X Mouse coordinates                           |
| mouse\_y       | Number | Y Mouse coordinates                           |

### on\_enable

This event will be called when the module gets enabled

### on\_disable

This event will be called when the module gets disabled
