> ## Documentation Index
> Fetch the complete documentation index at: https://v5.rpgjs.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Event hooks

> Hooks for events created as plain objects, as shown in the create-event guide.

# Event hooks

Hooks for events created as plain objects, as shown in the create-event guide.

## Members

* [onAction](#onaction)
* [onChanges](#onchanges)
* [onDetectInShape](#ondetectinshape)
* [onDetectOutShape](#ondetectoutshape)
* [onInit](#oninit)
* [onInShape](#oninshape)
* [onOutShape](#onoutshape)
* [onPlayerTouch](#onplayertouch)

## onAction

Called when a player performs an action on this event

* Source: `packages/server/src/rooms/map.ts`
* Kind: `property`
* Defined in: `EventHooks`

### Signature

```ts theme={null}
onAction: (this: RpgEvent, player: RpgPlayer) => void
```

## onChanges

Called during the change-detection cycle for the current player.

Use this hook to recompute the event state from player data, especially
player variables. This is useful for reactive visuals such as an opened
chest, a hidden door, or a conditional NPC graphic.

* Source: `packages/server/src/rooms/map.ts`
* Kind: `property`
* Defined in: `EventHooks`

### Signature

```ts theme={null}
onChanges: (this: RpgEvent, player: RpgPlayer) => void
```

## onDetectInShape

Called when a player is detected entering a detection shape attached to the event

* Source: `packages/server/src/rooms/map.ts`
* Kind: `property`
* Defined in: `EventHooks`

### Signature

```ts theme={null}
onDetectInShape: (this: RpgEvent, player: RpgPlayer, shape: RpgShape) => void
```

## onDetectOutShape

Called when a player is detected exiting a detection shape attached to the event

* Source: `packages/server/src/rooms/map.ts`
* Kind: `property`
* Defined in: `EventHooks`

### Signature

```ts theme={null}
onDetectOutShape: (this: RpgEvent, player: RpgPlayer, shape: RpgShape) => void
```

## onInit

Called when the event is first initialized.

Use this hook for default setup that does not depend on a player interaction,
such as setting the initial graphic, speed, or movement route.

* Source: `packages/server/src/rooms/map.ts`
* Kind: `property`
* Defined in: `EventHooks`

### Signature

```ts theme={null}
onInit: (this: RpgEvent) => void
```

## onInShape

Called when a player enters a shape attached to the event

* Source: `packages/server/src/rooms/map.ts`
* Kind: `property`
* Defined in: `EventHooks`

### Signature

```ts theme={null}
onInShape: (this: RpgEvent, zone: RpgShape, player: RpgPlayer) => void
```

## onOutShape

Called when a player exits a shape attached to the event

* Source: `packages/server/src/rooms/map.ts`
* Kind: `property`
* Defined in: `EventHooks`

### Signature

```ts theme={null}
onOutShape: (this: RpgEvent, zone: RpgShape, player: RpgPlayer) => void
```

## onPlayerTouch

Called when a player touches this event

* Source: `packages/server/src/rooms/map.ts`
* Kind: `property`
* Defined in: `EventHooks`

### Signature

```ts theme={null}
onPlayerTouch: (this: RpgEvent, player: RpgPlayer) => void
```
