Authoritative turn-based multiplayer games?

Hi folks,

Is there any active turn based game tutorial or walkthrough using nakama server? Or how to create authoritative turn-based multiplayer games? Want to discuss this in detail.

Thanks

Hi Faisal,

Let say that I have created a game using lua following the docs Full example code


Now you save the file with name pingpong.lua

You can create a match using LUA like this

local modulename = "pingpong"
local setupstate -- the data you want to pass to the match (for example the players matched using matchmaker )
local matchid = nk.match_create(modulename, setupstate)

nk.match_create(modulename, setupstate) usually is excuted after a group of players are matched together using matchmaker

like below

local function makematch(context, matched_users)
     local setupstate = matched_users
     local matchid = nk.match_create(modulename, setupstate)
     return matchid
end
nk.register_matchmaker_matched(makematch)

or It can be executed using RPC call

local function create_match_private(context, payload)
    local setupstate = 
    {
        created_by = context.username,
        invited = {},
        -- add any data you want to pass to the match
   }
local matchid = nk.match_create(modulename, setupstate)
return matchid
nk.register_rpc(create_private_match, "PrivateMatch") -- private match

Now inside pingpong.lua which you have created on the begging you can make the rules to allow the players to join and also make the logic of the game

players will be able to join the match using the match Id generated by nk.match_create(modulename, setupstate)

For more about authoritative multiplayer read this

2 Likes

Alright, i will read the docs in details, thanks for pointing this out and explaining. I have another question.

Is there any user properties like thing in nakama multiplayer ? e.g i want to set user location, inventory values and other things in user properties so that i can have match maker to search opponent based on these values, how can i do this ?

I m new to nakama and in learning state. Thanks.

Is there any user properties like thing in nakama multiplayer ? e.g i want to set user location, inventory values and other things in user properties so that i can have match maker to search opponent based on these values, how can i do this ?

You can do it in many ways it depends on how the data going to be used and by whom

1.Account Metadata

You can save users data like level, cups , score and more on player’s account metadata
Account metadata is :
public (it can be seen by others players),
Limited (16KB per user) ,
Read-only (Set only by server script - Lua in your case)

Read more

2.Virtual wallet

  Private (only read by the player (owner)  and read-write via server script)
  You can use it to represent how much coins, money,,,and gold the players have 

Read more

3.Collections

Yo can store the data here as you like and specify if public/private read/write

Read more