# Other

{% hint style="danger" %}
You should always make sure that you are calling these events after the rcore\_stats script is initialized.

To make sure, check the Step 1 in the [Integration](https://documentation.rcore.cz/paid-resources/rcore_stats/api/integration) guide.
{% endhint %}

### Open UI

If you want to open the UI for example from some target script, you can use this event (this is CLIENT SIDE):

```lua
TriggerEvent('rcore_stats:api:openUI')
```

### Achievement unlocked event

If you want to for example give a reward to the player when they unlock an achievement, you can do it like this.

**CLIENT SIDE:**

```lua
AddEventHandler('rcore_stats:api:achievementUnlocked', function(achievementKey)
    if achievementKey == "basket_hoops_1" then
        -- Give the player a reward because they shot their first hoop in basketball
    end
end)
```

or

**SERVER SIDE**

```lua
AddEventHandler('rcore_stats:api:achievementUnlocked', function(playerId, achievementKey)
    if achievementKey == "basket_hoops_1" then
        -- Give the player with playerId a reward because they shot their first hoop in basketball
    end
end)
```

### Stat value getter

If you want to get the value of the stat type for the player, you can do it like this (this is CLIENT SIDE):

As event:

```lua

-- @param key string - unique key of the stat type
-- @param cb function - callback function that will be called with the value of the stat type
TriggerEvent('rcore_stats:api:getStatValue', key, cb)

-- Example to get the value of the stat type "basket_hoops" with event
TriggerEvent('rcore_stats:api:getStatValue', "basket_hoops", function(value)
    print("Player has scored " .. value .. " points in basketball")
end)
```

As export:

```lua
exports["rcore_stats"]:getStatValue(key)

-- Example to get the value of the stat type "basket_hoops" with exports
local value = exports["rcore_stats"]:getStatValue("basket_hoops")
```
