# Event handling

The server provides a few events that you can listen to.

### HogWarpSdk.Server.World.UpdateEvent

This simple event is called every frame and passes the delta time in seconds since the previous frame.

Example usage:

```csharp
public Plugin()
{
    HogWarpSdk.Server.World.UpdateEvent += MyUpdate;
}

private void MyUpdate(float Delta)
{
    // Do something
}
```

### HogWarpSdk.Server.PlayerSystem.PlayerJoinEvent

This simple event is called when a player joins the server, it passes the player, at this point all spawned actors are already valid and Rpcs can be called.

```csharp
public Plugin()
{
    HogWarpSdk.Server.PlayerSystem.PlayerJoinEvent += PlayerSystem_PlayerJoinEvent; 
}

private void PlayerSystem_PlayerJoinEvent(HogWarpSdk.Game.Player player)
{
    // Yay we have a new player!
}
```

### HogWarpSdk.Server.PlayerSystem.PlayerLeftEvent

This simple event is called when a player leaves the server, it passes the player, note that at this point it would serve no purpose to make Rpc calls to that player, they are already disconnected.

```csharp
public Plugin()
{
    HogWarpSdk.Server.PlayerSystem.PlayerLeftEvent += PlayerSystem_PlayerLeftEvent; 
}

private void PlayerSystem_PlayerLeftEvent(HogWarpSdk.Game.Player player)
{
    // Oh no a player left :'(
}
```


---

# 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://docs.hogwarp.com/hogwarp/scripting/server-side/event-handling.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.
