Create Unity leaderboard

hello, is there any way to create a leaderboard without server-side code or Lua, Go languages?
I should learn about Lua or go? I’m implementing server-side logic by unity and I can not communicate with Nakama.

Hi @hooman welcome :wave:

is there any way to create a leaderboard without server-side code or Lua, Go languages?

The server requires a leaderboard to be created ahead of use via a small amount of server code in Lua or in Go. This prevents bad actors from abusing the server API to create leaderboards that were not intended for the game. These authoritative controls are important to protect the integrity of the game design and your server infrastructure.

I’m implementing server-side logic by unity and I can not communicate with Nakama.

What does this mean? You want to use Nakama server but cannot communicate with it. How would this work with your game project?

thank you, I want to use unity ECS and Transport to create my server, then I can use ECS physics. but I need authentications, leaderboards, and other social features that take a long time to write. I’m not using Nakama in realtime.

@hooman I understand now. Thanks for the added details.

You can of course use Nakama for the social, core game data, and realtime but non-multiplayer features in your game project. We have lots of game teams who combine Nakama with another system for their project if the requirements need it.

As for how to create a leaderboard from Unity do you need to create leaderboards dynamically from the headless instance?

thank you for your answer and sorry for my English.
I have the wrong title on this topic.
there are two pieces of feedback on this topic.
at my requirement, I can not create or remove leaderboards from the dashboard and I should change server code to create or remove Leaderboards.
at second requirement, an example of server-side controlling:
yes, I have a headless instance of the game as a game server that running with Nakama.
currently, players should submit leaderboard records or storage collections from their client-side game. then I think hackers can cheat. I have created a game server instance that processing the physics of the game by Unity Dots. I can not send the score to the client and submit it to the Nakama leaderboard. I want to add them directly from the server but I can’t link my c# game server and Nakama server. I should upload the player username and password to the game server and submit the leaderboard. it’s not the correct way. and players should not have permission to modify the leaderboard from the client.

yes, I have a headless instance of the game as a game server that running with Nakama.
currently, players should submit leaderboard records or storage collections from their client-side game. then I think hackers can cheat. I have created a game server instance that processing the physics of the game by Unity Dots. I can not send the score to the client and submit it to the Nakama leaderboard. I want to add them directly from the server but I can’t link my c# game server and Nakama server.

@hooman This is easy because the game server supports server to server (S2S) RPC functions. You’d have your headless game server instance execute an RPC and write the scores for your players. This is covered in the docs here:

https://heroiclabs.com/docs/runtime-code-basics/#server-to-server

In the Unity client you can make a server to server RPC function call with the method on the client object called client.RpcAsync(string httpKey, string id, string payload = null).

ok, then I should create a Lua script to register the RPC hook and call RPC to access the server. where can I find an example? I want to verify the auth token at the server. or add a record and more…

@hooman Have you had a look at the docs and tried to write any runtime code?

yes, I’ve seen documents but I’m searching for a way without Lua or go languages.
thank you, I will start learning Lua next month.

@hooman We will also have JavaScript engine support in the game server in our next release in January. You should keep an eye out for that release in case you’re more comfortable with JavaScript/TypeScript development.

In the meantime you could just pass the session token for each player and store it server-side within your headless instance wherever you maintain the list of connected players. Then use the session token with each player to just send the leaderboard writes with the standard client object.

https://heroiclabs.com/docs/gameplay-leaderboards/#submit-a-score

Hope this helps.

2 Likes