• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

UWP UWP Leaderboard Help

Hi,
I have a game currently being tested on the Microsoft Store via UWP. Looking at the UWP documentation, it says that I can use leaderboards. I read up the little information offered by YoYo and a bit from Microsoft and tried to implement these into my game. However I am yet to have success with this endeavour. Despite trying multiple times I still don't see these leaderboards anywhere and I was hoping someone more experienced with this could inform me if my MS Partner Setup or code is wrong.
This is the code I use to write to the leaderboard (NOTE: I had to remove certain parts as they are part of the certificate copied from MS Partner Center but these are replaced with // followed by what they are):
Code:
if os_type = os_uwp and xboxlive_user_is_signed_in()
{
    xboxlive_stats_setup(xboxlive_get_user(0), "//Game SCID", //Game Title Id);
    xboxlive_stats_set_stat_int(xboxlive_get_user(0), "Score", score);
    xboxlive_stats_set_stat_int(xboxlive_get_user(0), "Level", global.level);
}
(I also tried in the string parameter entering the display name of the leaderboard to little success

This is how I have the leaderboards set up in MS Partner Center:


I have also used the following documents to help:
https://docs.microsoft.com/en-us/ga...-platform-for-stats-leaderboards-achievements
https://docs.microsoft.com/en-us/gaming/xbox-live/leaderboards-and-stats-2017/leaderboards
GMS2 Docs for xboxlive_stats_setup(); and xboxlive_stats_set_stat_int();

As I said I can't see any changes anywhere and so it would be nice if someone more experienced than me could let me know if my code is the issue or if my setup on MS Partner is an issue.
Thanks for reading!

(PS: I previously accidentally posted this in GMS2 Community Tech Support so if you've seen this before, that's why. I have asked for it to be removed)
 

TravsVoid

Member
Did you ever figure this out? On my end I get errors like this:

Error : Cannot combine XBox Live 2013 and 2017 statistic and achievement system methods.
2013 methods: "xboxlive_stats_setup", 2017 methods: "xboxlive_stats_add_user"


So I only used xboxlive_stats_add_user which does seem to allow xboxlive_stats_set_stat_int to do something and I can read the stat with xboxlive_stats_get_stat but it can only get the stat after using the previous set_stat_int function. When I relaunch the game and try to get the stat it returns undefined like it's not saving the stat. Another thing I noticed is that xboxlive_stats_add_user I can't seem to get any async system event like it says is supposed to trigger.
 

TravsVoid

Member
Ok now when I run xboxlive_stats_get_stat right after launching the game I'm getting one of the random numbers I set it to earlier. I tried changing it again with xboxlive_stats_set_stat_int but when I restart the game it still shows the older number I set it to earlier. Maybe stats have a delay or something but it's been at least 30 minutes and it's still showing the older number.
 
For if I ever figured this out, the short answer is no.

The long answer is that I found out it's very messy. As far as I can tell, there are two types of Leaderboard system. The 2013 version and the 2017 version. You can use one or the other but not both (hence your error above). The fact that you've actually been able to read in a stat is something I couldn't figure out so you're ahead of me in that regard. I just wish they would release documentation on how this all works and a lot more to do with UWP as it's just a wasteland at this point. There's documentation on Microsoft's side but that's all for Visual Studio and not GML which is why stuff is needed for UWP. Although I haven't tried it, if you want leaderboards the best thing probably is to use a third party extension to make it. I'm sure there are plenty of tutorials on that since I get recommended them occasionally. That's all I can offer I'm afraid...
 

TravsVoid

Member
I did some more testing and still can't figure out how to get a leaderboard (Maybe it requires more than one user being registered for that stat?) but I have gotten stats themselves to set and read correctly. For some reason you have to remove the user after saving a stat or once you relaunch the game and try getting the stat again you will notice it never saved it. Here is what I'm using to save a stat:

GML:
xboxlive_stats_set_stat_int(userID, "TestStat", testScore);
xboxlive_stats_remove_user(userID);
After that you will need to use the add_user function before running any stat functions again:

GML:
xboxlive_stats_add_user(userID);
If you use a get_stat function without adding a user first it returns undefined. Also if you've never set a stat for the user before that stat will return undefined not 0.

The docs for UWP seem outdated and I've sent a few bug reports on various things. Getting cloud saves was just as much a hassle as this due to the documentation definitely not being clear on a few things but it seems to work although I'm not sure if I've done it correctly (publishing a basic game soon and will find out). But I can save when running the game on my PC and then open the game on my Xbox and it syncs the save.
 

TravsVoid

Member
I read more about how stats are saved to the servers and found out that once you initialize stats xboxlive_stats_add_user there is a 5 minute interval started where set stats are sent to the servers. You can use xboxlive_stats_flush_user to send it to the servers faster. If you set the priority of the flush to 0 it writes to the server on a 30 second timer. If you set the priority to 1 it immediately writes pending stats but you can only run this function with high priority every 30 seconds.
 
Top