Hey there, I´m pretty new to Nakama and would like to know if it´s possible to get a list of all current running match IDs from a client? So I can show them on the client and connect to a specific one manually without the matchmaking. I know about nk.match_list() but can´t get it to work to return all matches no matter what config the matches have. Can someone please help me with that?
Hi @Mullo welcome
What code have you tried to return all active matches from the server? Please share and we can help.
I have created a match in godot with var created_match : NakamaRTAPI.Match = yield(socket.create_match_async(), "completed")
and are trying to receive all matches with the following RPC call:
function list_matches(context, payload)
local limit = 10
local authoritative = false
local min_size = 0
local max_size = 1200
local filter = ""
local matches_list = nk.match_list(limit, authoritative, nil, min_size, max_size, filter)
local response = {}
if(matches_list) then
local no_of_matches = #matches_list
nk.logger_info("[search_matches/list_matches] : Found matches Count : " .. no_of_matches)
if(no_of_matches == 0) then
nk.logger_info("no matches found")
response["matches"] = nil
else
nk.logger_info("matches found")
response["matches"] = matches_list
end
else
nk.logger_info("no matches found")
response["matches"] = nil
end
return nk.json_encode(response)
end
Am I doing something completly wrong? I am receiving a match ID after I created the match so the connection to nakama is working but no_of_matches is always 0…
@Mullo Try using nil
for a filter instead of ""
, the two are not the same. Relayed matches (where authoritative == false
) do not have a label so your listing will likely filter to 0 matches every time as long as you search for ""
.
Ah I see. I will try that. Thanks for the help and by the way thanks for the great tool guys