# 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](/paid-resources/rcore_stats/api/integration.md) 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")
```


---

# 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_stats/api/other.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.
