Asset - Scripts UBG API [online scoreboards / save data]

Binsk

Member
NOTE: [Updated March 2021] This system will be getting a complete overhaul down the road.

Howdy! How would you like to have some online high-score boards for free?

This project is currently a heavy WIP and only a small subset of many planned features are implemented so far. If you have ideas / suggestions / bugs please let me know!

Goal


The goal of this extension is to provide those new to GameMaker an easy and free way to release their games with online high-scores. As these games are generally targeted towards the community or a group of friends this system is not to be used with commercial products. If you are just making a fun game casually that you plan on giving out for free then this extension is for you.

This entire project is also a learning experience for me so any feedback is welcome. I plan to make my own game for every feature I add to make sure that it works well and is easy to use, however, so things should hopefully be made solidly.

About

The online high-scores will be stored in a database on my website, Upset Baby Games. This requires that you have an account on the website in order to generate some API keys. API keys are responsible for controlling where data goes, how it is stored, and for whom. This also allows you to hop in and modify your scoreboards and whatnot as needed through your account page.

Currently you can make a simple top-10 scoreboard, a normal multi-user scoreboard, and you can sync online user data. I hope to add a simple server list system down the road as well to help with finding online games.

This extension provides some scripts that interface with my server to add and retrieve score data, log users in, and so forth. It also provides an example with a dummy API key as a demonstration.

More info can be found in the online documentation (currently A WIP).

Downloads / Examples:

You can download the extension from two places:
My website (once logged in with a developer account)
Yoyo Marketplace (can only modify not create data unless you have a UBG account)

An example game that uses the system is hosted on my site as well (made with a different engine but it uses the same API).

If you have any questions please feel free to ask them here.
 
Last edited:

FrostyCat

Redemption Seeker
On your documentation, remember to check your syntax. For example, this won't work on GMS 2:
GML:
if (ubg_api_has_data()){
    var _data = ubg_api_get_data(); // Grab our data
    if (ubg_api_get_command_last() == "top10_get_scores"){
        var _names = _data['names'],    // Grab the values to print
            _scores = _data['scores'];
    for (var i = 0; i < _data['size']; ++i) // Loop through our data and print the scores:
        show_debug_message(_names[i] + ": " + string(_scores[i]));
    }
}
 

Binsk

Member
On your documentation, remember to check your syntax. For example, this won't work on GMS 2:
GML:
if (ubg_api_has_data()){
    var _data = ubg_api_get_data(); // Grab our data
    if (ubg_api_get_command_last() == "top10_get_scores"){
        var _names = _data['names'],    // Grab the values to print
            _scores = _data['scores'];
    for (var i = 0; i < _data['size']; ++i) // Loop through our data and print the scores:
        show_debug_message(_names[i] + ": " + string(_scores[i]));
    }
}
Whoop! Gracious, good catch, I must have been on something when I wrote that up. Thank you very much.
 

Binsk

Member
Update!

Numerous changes since my last post:
  • Some client-side code has changed to auto-handle some POST sanitization rather than expecting the programmer to do so
  • Changed how some security-related data was sent to the server
  • Added support for 'unbound' highscore boards! You can now have simple top-10 boards when desired as well as boards that support any number of scores with multiple-level support
  • Added ability to toggle name repeats for top-10 boards
  • Added ability to generate a public scoreboard link. It is very simple at the moment and I will be adding customization options and optional formatting that will work with iframes smoothly.
  • Had a request to allow score submissions insecurely through GET methods. This option is now provided albeit it is disabled by default and should not be used for any projects that will be distributed.
 
Last edited:

Binsk

Member
Update!

I realize I just updated the system but here's another one!
  • Added ability to sync account data online! Currently only supports Upset Baby Games accounts but I will be adding other services for sure. Newgrounds next and I will be looking into Itch.IO.
  • Fixed some sanitization issues that showed up when submitting user data.
  • Updated the docs a bit to layout the more raw aspects of the API better. I will be adding a GameMaker setup tutorial later but for now the demos in the extension will have to do.
 
H

harambe1

Guest
Hello! Great work on this. I have implemented it to my project. However there is always a FATAL ERROR when adding score on top 10 (even on your demo project). What could be causing this?
 

Binsk

Member
@harambe1

Thank you for bringing this to my attention. A recent change on the server was causing the issue. It is fixed now. Thank you for giving the extension a shot!
 
H

harambe1

Guest
@harambe1

Thank you for bringing this to my attention. A recent change on the server was causing the issue. It is fixed now. Thank you for giving the extension a shot!
Hey no worries! Its an awesome API. Super easy to use. I do have a question though, ultimately I want my project to export in HTML. now the http request does not work on web versions (because of cross script stuff I think). Is there any workaround on this? or better yet, if I am hosting my game on my own website, is there an easier way to keep track of high scores? Thank you!
 

Binsk

Member
Hey no worries! Its an awesome API. Super easy to use. I do have a question though, ultimately I want my project to export in HTML. now the http request does not work on web versions (because of cross script stuff I think). Is there any workaround on this? or better yet, if I am hosting my game on my own website, is there an easier way to keep track of high scores? Thank you!
Unfortunately I do not as of yet have the HTML export module for GameMaker 2.x and thus cannot test this. That said, the cross-domain issues mentioned in the manual are usually handled between the server and the browser itself. I have my server set up to perform the proper pre-flight approval to allow cross-domain API calls. It should function just fine unless GameMaker specifically is doing something funky in the background.

In terms of an "easier way" to keep track of high scores, I am currently working on something. Right now you can enable "Public Access" for your API key through your developer account. It provides a public link people can go to to view your highscore table. Right now it is a simple page on my site but I will be adding a version intended for use in iframes where you can embed the score table directly on your webpage. If you were looking for something specific let me know.
 
H

harambe1

Guest
Thank you! Yeah I have seen some bug reports of GMS2 having http request errors for html5 export. I will look more into it. the API works perfectly on my Windows export, though! I am able to display everything in-game. Great job man.
 
H

harambe1

Guest
Unfortunately I do not as of yet have the HTML export module for GameMaker 2.x and thus cannot test this. That said, the cross-domain issues mentioned in the manual are usually handled between the server and the browser itself. I have my server set up to perform the proper pre-flight approval to allow cross-domain API calls. It should function just fine unless GameMaker specifically is doing something funky in the background.

In terms of an "easier way" to keep track of high scores, I am currently working on something. Right now you can enable "Public Access" for your API key through your developer account. It provides a public link people can go to to view your highscore table. Right now it is a simple page on my site but I will be adding a version intended for use in iframes where you can embed the score table directly on your webpage. If you were looking for something specific let me know.
just to let you know, I also tested it on Android! Works perfectly. It seems only web version is the problem
 
Top