# API

All exports and events that script provides for developers.

## Exports

### startTreeBuild

* Start prop placer for building tree.
* Side: `client`
* Usage:

```lua
--- void
exports.rcore_xmas:startTreeBuild()
```

### startSnowmanBuild

* Start prop placer for building snowman.
* Side: `client`
* Usage:

```lua
--- void
exports.rcore_xmas:startSnowmanBuild()
```

### isEntitySnowmanPart

* Returns true/false if provided entity is part of building process of man snowman
* Side: `client`
* Usage:

```lua
local entity = ...
--- snowmanPart: boolean (true/false)
local snowmanPart = exports.rcore_xmas:isEntitySnowmanPart(entity)

if snowmanPart then
    ...
end
```

### getTrees

* Returns table of all cached trees from database around map
* Side: `server`
* Usage:

```lua
--- {
---
---     [key: id]: string = {
---         model: int,
---         coords: vector3,
---         rotation: vector3,
---         heading: float,
---         owner: string
---     }: table
---
--- }: table
local cachedTrees = exports.rcore_xmas:getTrees()
for treeId, tree in pairs(cachedTrees) do
    local model = tree.model
    local coords = tree.coords
    local rotation = tree.rotation
    local heading = tree.model
    local owner = tree.model
    ...
end
```

### getTreesByOwner

* Returns table of all cached trees from database around map by provided owner id in parameter
* Side: `server`
* Usage:

```lua
local client = source?
--- {
---
---     [key: id]: string = {
---         model: int,
---         coords: vector3,
---         rotation: vector3,
---         heading: float,
---         owner: string
---     }: table
---
--- }: table
local trees = exports.rcore_xmas:getTreesByOwner(client)
```

### getCollectedPresents

* Returns all player's collected presents for present hunt directly and synchronously from database
* Side: `server`
* Usage:

```lua
local client = source?
--- {
---
---     [key: presentId]: string = boolean
---
--- }: table
local collectedPresents = exports.rcore_xmas:getCollectedPresents(client)
```

### getSpawnedSnowmans

* Returns all currently spawned snowmans.
* Side: `server`
* Usage:

```lua
--- {
---
---     [key: id]: string = Entity (number)
---
--- }: table
local snowmans = exports.rcore_xmas:getSpawnedSnowmans()
```

### isEntitySnowman

* Returns if entity in parameter is snowman built by script
* Side: `server`
* Usage:

```lua
--- boolean (true/false)
local entity = ...
if exports.rcore_xmas:isEntitySnowman(entity) then
    ...
end
```

### getPresentsPositions

* Returns table of all positions from `shared/present-hunt/sh-positions.lua` for present hunt
* Side: `shared`
* Usage:

```lua
--- {
---
---     {
---         position: vector3,
---         rotation: vector3
---     }: table
--
--- }: table
local presentsPositions = exports.rcore_xmas:getPresentsPositions()
```


---

# 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://documentation.rcore.cz/paid-resources/rcore_xmas/api.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.
