# API

## Server side events

## On events

### On spawn

#### Example data

```lua
--Example pointData
-- 96 is ID of point
[96] = {
    ["model"] = rcore_easter_egg_05,
    ["pos"] = vec3(383.593140, -1828.449097, 27.601067),
    ["spawnTime"] = 1711301043,
    ["id"] = 96,
    },
}
```

#### Example data

```lua
AddEventHandler(triggerName("onSpawnPoint"), function(pointData)
    --Spawned point
end)
```

### On delete

#### Example data

```lua
--Example point data
pointData = {
    ["id"] = 106,
    ["pos"] = vec3(1465.088379, -1890.619873, 70.719093),
}
```

#### Example code

```lua
AddEventHandler(triggerName("onDeletePoint"), function(pointData)
    --Deleted point
end)
```

### On pickup

#### Example data

```lua
--Example pointData
-- 96 is ID of point
[96] = {
    ["model"] = "rcore_easter_egg_05",
    ["pos"] = vec3(383.593140, -1828.449097, 27.601067),
    ["spawnTime"] = 1711301043,
    ["id"] = 96,
    },
}
```

#### Example code

```lua
AddEventHandler(triggerName("onSelectPoint"), function(playerId, pointData)
    --On pickup
end)
```

## Own reward

For this to work go to config and change value to true. If you change this to true our script will not give items to player and it will call server event with playerId, point data and model data where you can find values from config.

```lua
Config.UseOwnReward = true
```

#### Example data

```lua
--Example pointData
pointData = {
    ["id"] = 96,
    ["pos"] = vec3(383.593140, -1828.449097, 27.601067),
    ["spawnTime"] = 1711301043,
    ["model"] = rcore_easter_egg_05,
}

--Example modelData
modelData = {
    ["reward"] = {
        [1] = {
            ["name"] = bread,
            ["count"] = 1,
            },
        [2] = {
            ["name"] = water,
            ["count"] = 1,
            },
        },
    ["rewardCount"] = 2,
    ["model"] = "rcore_easter_egg_05",
}
```

#### Example code

```lua
AddEventHandler(triggerName("reward"), function(playerId, pointData, modelData)

end)
```


---

# 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_easter/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.
