Client
.NET/Unity C++/Unreal/Cocos2d-x JavaScript/Cocos2d-js Godot 3 Godot 4 Java/Android Defold cURL REST Swift Dart/Flutter
Server
TypeScript Go Lua
Unlockables
# Read more about the Unlockables system in Hiro here .
Functions
# Create
# Place a new unlockable into a slot either randomly, by ID, or optionally using a custom configuration.
1
2
3
4
5
6
7
8
userId := "userId"
unlockableId := "unlockableId"
unlockableConfig := & hiro . UnlockablesConfigUnlockable {}
unlockables , err := systems . GetUnlockablesSystem (). Create ( ctx , logger , nk , userId , unlockableId , unlockableConfig )
if err != nil {
return err
}
Get
# Get all unlockables active for a user.
1
2
3
4
5
6
userId := "userId"
unlockables , err := systems . GetUnlockablesSystem (). Get ( ctx , logger , nk , userId )
if err != nil {
return err
}
UnlockAdvance
# Add the given amount of time towards the completion of an unlockable that has been started.
1
2
3
4
5
6
7
8
userId := "userId"
instanceId := "instanceId"
var seconds int64 = 3600
unlockables , err := systems . GetUnlockablesSystem (). UnlockAdvance ( ctx , logger , nk , userId , instanceId , seconds )
if err != nil {
return err
}
UnlockStart
# Begin an unlock of an unlockable for a user.
1
2
3
4
5
6
7
userId := "userId"
instanceId := "instanceId"
unlockables , err := systems . GetUnlockablesSystem (). UnlockStart ( ctx , logger , nk , userId , instanceId )
if err != nil {
return err
}
PurchaseUnlock
# Immediately unlock an unlockable for a user.
1
2
3
4
5
6
7
userId := "userId"
instanceId := "instanceId"
unlockables , err := systems . GetUnlockablesSystem (). PurchaseUnlock ( ctx , logger , nk , userId , instanceId )
if err != nil {
return err
}
PurchaseSlot
# Create a new slot for a user.
1
2
3
4
5
6
userId := "userId"
unlockables , err := systems . GetUnlockablesSystem (). PurchaseSlot ( ctx , logger , nk , userId )
if err != nil {
return err
}
Claim
# Claim an unlockable which has been unlocked for the user.
1
2
3
4
5
6
7
userId := "userId"
instanceId := "instanceId"
reward , err := systems . GetUnlockablesSystem (). Claim ( ctx , logger , nk , userId , instanceId )
if err != nil {
return err
}
QueueAdd
# Add one or more unlockables to the queue to be unlocked as soon as an active slot is available.
1
2
3
4
5
6
7
userId := "userId"
instanceIds := [] string { "instanceId_001" , "instanceId_002" }
unlockables , err := systems . GetUnlockablesSystem (). QueueAdd ( ctx , logger , nk , userId , instanceIds )
if err != nil {
return err
}
QueueRemove
# Remove one or more unlockables from the unlock queue, unless they have started unlocking already.
1
2
3
4
5
6
7
userId := "userId"
instanceIds := [] string { "instanceId_001" , "instanceId_002" }
unlockables , err := systems . GetUnlockablesSystem (). QueueRemove ( ctx , logger , nk , userId , instanceIds )
if err != nil {
return err
}
QueueSet
# Replace the entirety of the queue with the specified instance IDs, or wipes the queue if no instance IDs are given.
1
2
3
4
5
6
7
userId := "userId"
instanceIds := [] string { "instanceId_001" , "instanceId_002" }
unlockables , err := systems . GetUnlockablesSystem (). QueueSet ( ctx , logger , nk , userId , instanceIds )
if err != nil {
return err
}
Hooks
# SetOnClaimReward
# Set a custom reward function which will run after an unlockable’s reward is rolled.
1
2
3
4
5
6
systems . GetUnlockablesSystem (). SetOnClaimReward ( OnClaimReward )
func OnClaimReward ( ctx context . Context , logger runtime . Logger , nk runtime . NakamaModule , userID , sourceID string , source * hiro . UnlockablesConfigUnlockable , rewardConfig * hiro . EconomyConfigReward , reward * hiro . Reward ) ( * hiro . Reward , error ) {
// Modify reward or take additional actions.
return reward , nil
}