Hi,
I am trying to write a custom RPC to get the leaderboard data, but I have encountered a weird behaviour. This is the code I have wrote to debug the leaderboard records to see if there are any records available:
local nk = require("nakama")
local function debug_leaderboard(context, payload)
local leaderboard_id = "doubleconnect_timetrial_leaderboard"
local limit = 50
local records = nk.leaderboard_records_list(leaderboard_id, nil, limit, nil, nil, nil)
if not records or not records.records then
return nk.json_encode({ status = "error", message = "No records found." })
end
return nk.json_encode({ status = "success", records = records.records })
end
nk.register_rpc(debug_leaderboard, "debug_leaderboard")
This code returns nothing. I don’t want any filter for the owners. first i tried {}
but I read from here that it should be nil
but it didn’t matter as I still don’t get any results.
I double-checked the ID for the leaderboards, and the records are available in the Console. Even when I use the ListLeaderboardRecords
API, I get the records. But somehow from the code above, no results are generated. What am I doing wrong here?