# HAPI Methods

The HAPI class has multiple methods to save you time and enhance your workflow.

### Finding an object by name near a position

Sometimes there's multiple objects with the same name so if you have your object position you can use this method to find it more accurately.

{% tabs %}
{% tab title="Method" %}

```csharp
GameObject FindGameObjectNearPos(string name, Vector3 position)
// This allows you to get the nearest object from this position that matches the name.
```

{% endtab %}

{% tab title="Example" %}

```csharp
GameObject overpassRoadpart = HAPI.FindGameObjectNearPos("30 Wedge", new Vector3(-8.20f, 0, -45.58f));
```

{% endtab %}
{% endtabs %}

### Finding an object by its hierarchy path

This is probably the most accurate way of finding buildings or static objects if you want to interact with them.

{% tabs %}
{% tab title="Method" %}

```csharp
GameObject FindGameObjectByPath(string path)
// This allows you to get an object by its hierarchy path
```

{% endtab %}

{% tab title="Example" %}

```csharp
GameObject overpass = HAPI.FindGameObjectByPath("Map/Container/Overpass");
```

{% endtab %}
{% endtabs %}

### Saving the game

This one is pretty simple as you just call it to save the game.

```csharp
HAPI.SaveGame();
```

### Teleporting a player somewhere

HAPI gives you an extension method for the Player class so you can teleport an user wherever you want.

```csharp
player.Teleport(new Vector3(0,0,0));
```

### Kicking a player

Kicking a player can be done through the Kick extension method.

{% tabs %}
{% tab title="Method" %}

```csharp
void Kick(this Player player, string reason = "You have been kicked from the server !")
```

{% endtab %}

{% tab title="Example" %}

```csharp
thePlayer.Kick("Get out of here.");
```

{% endtab %}
{% endtabs %}

### Banning a player

Banning a player can also be done using HAPI with the Ban extension method.

{% tabs %}
{% tab title="Method" %}

```csharp
void Ban(this Player player, string reason = "You have been banned from the server !")
```

{% endtab %}

{% tab title="Example" %}

```csharp
thePlayer.Ban("You'll never come back again.");
```

{% endtab %}
{% endtabs %}


---

# 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/hapi-methods.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.
