> For the complete documentation index, see [llms.txt](https://docs.settlers-united.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.settlers-united.com/s4-lua-api-de/su-library-functions/su.buildings/su.buildings.getfirstbuildinginarea.md).

# SU.Buildings.GetFirstBuildingInArea

## SU.Buildings.GetFirstBuildingInArea(playerId, buildingType, x, y, radius)

Gibt die Entity-Id des ersten gefundenen Gebäudes im gegebenen Bereich zurück.

#### Parameter

* `playerId`: ID des Spielers (1-8), -1 wenn keine Spieler gefiltert werden sollen
* `buildingType`: ID des Gebäude-Typs (siehe [Enum-Tabelle](/s4-lua-api-de/api-enums/buildings.md)), -1 wenn keine Gebäude-Typen gefiltert werden sollen
* `x`: x-Koordinate des Bereichs
* `y`: y-Koordinate des Bereichs
* `radius`: Radius des Bereichs

#### Rückgabewert

* Entity-Id vom Gebäude
* 0: wenn kein Gebäude gefunden wurde

#### Beispiel

<pre class="language-lua"><code class="lang-lua">local buildingId = SU.Buildings.GetFirstBuildingInArea(playerId, buildingType, x, y, radius)
<strong>
</strong><strong>local buildings = SU.Buildings.GetFirstBuildingInArea(-1, -1, 115, 70, 10)
</strong><strong>-- Irgendein Gebäude bei 115/70 im Radius von 10
</strong>	if buildingId > 0 then
		dbg.stm(buildingId) -- Entity-Id des Gebäudes, wenn gefunden
	endl
end
</code></pre>


---

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

```
GET https://docs.settlers-united.com/s4-lua-api-de/su-library-functions/su.buildings/su.buildings.getfirstbuildinginarea.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.
