Problem with list leaderboard from lua runtime function

Hello everyone, I’m using Nakama server v2.12.0, I need to create an rpc function that takes the lines of a leaderboard and sends a notification to all users on that leaderboard. The problem is that when I use the “nk.leaderboard_records_list(id, owners, limit)” function I always get an empty array. In the parameters I put the id of the leaderboard I want to consult, as owners I putan empty object (it’s optional) and as limit I put 100. The leaderboard id I put is correct, it is a leaderboard with many records. Can someone tell me what I’m wrong? Thanks.

@antoniocapizzi95 What does the specific code you use look like? There’s no known issue with that server function. Are you sure you iterate over the returned LTable correctly?

I’m using this code:

local records, owner_records, next_cursor, prev_cursor = nk.leaderboard_records_list(id, owners, limit)

As id I put the id of a leaderboard containing a lot of rows. After I return the length of “records” (is a table) and I obtain 0. This is strange, because if i try to get the same leaderboard from client (with Unity library), i get 100 rows (i set the limit to 100).

@antoniocapizzi95 Have you checked the contents of owner_records? If you’re filtering the request by owners that should contain the appropriate filtered results.

I am having this exact same issue. Here is the code I am using. It returns an empty table.

local id = "league1-tier-1"
local owners = {}
local limit = 100
local cursor = ""
local overrideExpiry = 3600
local records, ownerRecords, nextCursor, prevCursor = nk.leaderboard_records_list(id, owners, limit, cursor, overrideExpiry)
local resp = {records = records, ownerRecords = ownerRecords, nextCursor = nextCursor, prevCursor = prevCursor}

return nk.json_encode(resp)

UPDATE
The documentation seems to be wrong/out of date. You need to pass nil for the owners parameter. If you pass an empty table {} as stated in the official lua runtime example, you will get an empty result set.

@SirCez we’ll change the documentation to make it clearer clearer. cc @HeroicNathan.

1 Like