Combu: leaderboards and more for Unity, on your server

Posted by on Jul 12, 2014 in Gamedev, Tech Stuff | One Comment

Until a few months ago, I used to rely on an online platform for the leaderboards of my games. It was easy to use and free within a limited amount of users, so I was happy. But there was a con, which I realized only later: being an online platform, I had to rely on someone else’s servers for my leaderboards to work. So when that online platform started hiccuping there was nothing I could do. Players started complaining with me (obviously) that the highscores weren’t loading nor uploading, while the online platform support seemed unable to fix the situation for a long time (I don’t even know if they fixed it by now). So I finally decided I had to move on a system that would be totally under my control and would reside on my own server. Too bad I’m not a database expert, and I know PHP only averagely. So. Enter Combu, which saved my games.

Combu

What is Combu?

Well, first and foremost, Combu is a Unity plugin (you can get it on the Asset Store or directly from the author’s website) created by Francesco Crocetti, which allows to manage online leaderboards and a lot more. It’s divided in two main parts…

The Unity files

Part of Combu is imported directly into your Unity project, giving you a load of APIs to interact with online players data, like leaderboards, accounts, mail notifications, inventories, news. It’s a very complete package and extremely simple to use, thanks to a very straightforward API which makes a smart use of events. This is a list of the current features (as of v1.4.3):

  • Users: create, login, update, load, delete, change password, exists, load random
  • Leaderboards: load leaderboard, highscores (overall, monthly, weekly, daily), post score
  • Contacts: load, add, remove contacts
  • Inventory: load, add/update item, remove item
  • Achievements: load achievements, progress
  • News: load
  • Mails: load, send, read, remove
  • Plus other miscellaneous stuff

The server files

The rest of Combu needs to be uploaded to your server, so it can connect your database with your Unity project, while also offering an online admin panel to check all your data and eventually add/delete/change things. Even if you don’t know shit about databases or php, Combu’s instructions make everything easy.

Observations

Combu can encrypt all the data you send to/from your Unity project, which is all you can ask security-wise. It will be up to you to protect your encryption key inside Unity, so that cheaters can’t access it (and for that I recommend Dmitriy Yukhanov’s Anti-Cheat Toolkit).

For what concerns highscores, Combu lets you choose between two options for each leaderboard. You can either store all user scores as they are sent, or keep a single score for every user, which increases each time you send a new one (useful for example in case of an online RPGs, to keep track of experience points). Personally, I prefer another option, but I’ll talk about it in the last paragraph.

Support-wise, Combu is fantastic. I was kind of a pain in the ass to Francesco while implementing it, but he always replied very quickly and with great efficiency.

So, Goscurry is now running on Combu and the highscores load very quickly, while everything resides on my own server so I don’t have to be worried of external platforms. All in all, I highly recommend Combu: it’s a very well made piece of software. Even money-wise it’s a great deal. With a one time fee you get a system you can re-use with all your games, while paying for a personal server is way cheaper than payed online services. And beware: I’m not payed to market Combu. I just really liked it, found myself very at ease with its implementation, and was extremely happy with the support.

A mod

As I mentioned, Combu leaderboards can either store every single score submitted, or a single sum of them all. Personally, I preferred another approach, which is to only keep the best overall/monthly/weekly/daily highscore for each user, in order to avoid overcrowding my database (when Goscurry will have tons of players — crossing my fingers very hard here). So I made a modification to a little part of the PHP code, and Francesco allowed me to post it here, in case you’re interested. But beware: I’m not a php/database expert, so you might find a better way to implement the same logic. If you do, let me know.

So. Get Combu and set it up. Then open the CB_Leaderboard.php file you find in the lib directory of the server contents. Get inside the last method there, PostScore, and replace this last line:

with this:

Then, in the same file, add this method and you’re done:

 

1 Comment

  1. Lior Rosenspitz
    February 11, 2018

    Thanks.
    I didn’t know this one.

    Reply

Leave a Reply