Other

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 guide.

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 (this is CLIENT SIDE):

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)

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:


-- @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:

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")

Last updated