# 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)
```
