# Plugin Events

Plugins can override event methods so they can be notified when specific things happens.\
For now there's only 3 events but more can be added upon request.<br>

{% tabs %}
{% tab title="OnWorldLoaded" %}
This event will be triggered when the game has finished loading the world/save.

```csharp
void OnWorldLoaded()
```

{% endtab %}

{% tab title="Example" %}

```csharp
public override void OnWorldLoaded()
{
    Log("The world has loaded!");
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="OnPlayerConnected" %}
This event will be triggered when a player connects to the server.

```csharp
void OnPlayerConnected(Player player)
```

{% endtab %}

{% tab title="Example" %}

```csharp
public override void OnPlayerConnected(Player player)
{
    Log($"{player.PlayerName} has joined the game!");
    player.SendChatMessage($"Welcome to the server {player.PlayerName}.");
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="OnPlayerDisconnected" %}
This event will be triggered when a player disconnects from the server.

```csharp
void OnPlayerDisconnected(Player player)
```

{% endtab %}

{% tab title="Example" %}

```csharp
public override void OnPlayerDisconnected(Player player)
{
    Log($"{player.PlayerName} has left the game!");
}
```

{% endtab %}
{% endtabs %}

Want more events ? DM me on discord with the events you'd like and i can take a look at adding it.


---

# Agent Instructions: 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:

```
GET https://schedule-i-dedicated-servers.gitbook.io/docs/plugin-events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
