I’m using Nakama 3.13.0 with Go modules on a dedicated multiplayer server. What’s the best way for the server to write/update player storage objects like their rank directly? I don’t think the client api has a user id field for writing at all and I am not sure if the console api was ever intended to be used like this.
First of all, I’d strongly encourage you to upgrade to latest Nakama, as version 3.13.0 is quite old at this stage.
We always keep backwards compatibility with the client, but you’ll likely need to update some of your runtime API calls if their signatures changed since.
What’s the best way for the server to write/update player storage objects like their rank directly
Ranks are a Leaderboards concept, so I’d just like to clarify if this is some data you’re storing in a storage object?
The client Storage APIs are bound to use the user’s session so they can only interact with objects they own or that are public.
If you’d like to allow a user to write objects that belong to other users or that are shared, you need to expose a customRPC and have your own ownership validation logic, then proceed to use the runtime function to update.
Hey, thank you for your response. I got this version from the assetstore and thought it was up to date but I will upgrade asap.
In our game, ranks would be just a number, that is publicly readable by anyone, only written to by a multiplayer server and incremented or decreased by the mutiplayer server at the end of a ranked match. These ranks would also be tracked on a leaderboard to give a global ranking.
My question is, if I was to create a customRPC, could I just call it with some sort of secret key from a multiplayer server to edit their rank and along with it the leaderboard?
We are switching over to nakama from playfab because we felt like it was just too much trouble working with them. On PlayFab we used something called a statistic to track ranks and it would also be used on a leaderboard to give a ranking. We are looking to achieve the same with nakama.
@PPreda got it, yes you can call a custom RPC authoritatively by another server by doing a Server-To-Server call.
S2S calls do not have a userId in the context, so you’d need to wire it up as part of the payload or some other param that would allow you to look up the player.