> For the complete documentation index, see [llms.txt](https://rplus.ollieee.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rplus.ollieee.xyz/event-system/events-overview.md).

# Events Overview

Socket Events are called whenever a specific action / event happens. There are currently 4 possible types of event that you could listen for:

* Chat Event
* Entity Event
* Team Event
* Protobuf Event

These will be called by the socket when the respective events occur. Here are some example usages:

{% code title="listeners.py" %}

```python
from rustplus import EntityEventPayload, TeamEventPayload, ChatEventPayload, ProtobufEvent, ChatEvent, EntityEvent, TeamEvent


# You must call get_entity_info(eid) before an EntityEvent listener will receive any data. 
# This is to "subscribe" to the entity.

@EntityEvent(server_details, 25743493)
async def alarm(event: EntityEventPayload):
    value = "On" if event.value else "Off"
    print(f"Entity has been turned {value}")


@TeamEvent(server_details)
async def team(event: TeamEventPayload):
    print(f"The team leader's steamId is: {event.team_info.leader_steam_id}")


@ChatEvent(server_details)
async def chat(event: ChatEventPayload):
    print(f"{event.message.name}: {event.message.message}")


@ProtobufEvent(server_details)
async def proto(data: bytes):
    print(data)
```

{% endcode %}

### Entity Event

The `entity_event` decorator takes an extra parameter of the [entity id](/getting-started/getting-player-details/getting-entity-ids.md) that you are listening for changes to. The `EntityEvent` object holds information on the entity:

| Name                | Description                           |
| ------------------- | ------------------------------------- |
| `entity_id`         | The Entity Id                         |
| `value`             | The value of the entity, `boolean`    |
| `capacity`          | The capacity of the entity            |
| `has_protection`    | Whether the entity is protected by TC |
| `protection_expiry` | When the protection by TC will expire |
| `items`             | The items that the entity contains    |

### Team Event

This event is typically called when the team changes, e.g. a player leaves or joins. The `team_event` decorator will pass a `TeamEvent` object as a parameter with the following information:

| Name          | Description                                                                   |
| ------------- | ----------------------------------------------------------------------------- |
| `player_info` | The `player_id` of the changed information                                    |
| `team_info`   | The [`team info`](/api-methods/getting-team-info.md) on the team that changed |

### Chat Event

This event is called when a message is sent to the team chat. It will give you a `ChatEvent` object when called with this information:

| Name      | Description                                                    |
| --------- | -------------------------------------------------------------- |
| `message` | The [message](/api-methods/getting-team-chat.md) that was sent |

### Protobuf Event

This event is called when protobuf is received over the websocket connection. This is for monitoring only. You are given the raw bytes of the message as a parameter.

### Removing

To remove any listener see:

{% content-ref url="/pages/J61lPJCX1zHo1AKgD7Xl" %}
[Removing Listeners](/api-methods/removing-listeners.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://rplus.ollieee.xyz/event-system/events-overview.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
