[SOLVED] HTML 5 Game with save to multiple users

Hi folks,
I’ve tested de xml save and load for local games. So, ok, it works great!
Than I’ve tested de Json with webstorage, and parsing some data to a variable. So… ok too.

But, I have a doubt about how the Json file will work with multiple users. For example, to create a HTML5 game I need to use a webstorage to save and load(not a local file with xml, but a Json file on a host ), but Let’s supose the game will have thousands of downloads, and every user saves and loads ( json and webstorage). So, here comes the question:

What’s the best way to storage those multiple users saves and loads? Shold be createad an incremental json file name for each user( in this case I’ll have thousands of different json files in the host )? Or only one json file with diffents users Ids( but in this case witch should be the best way to parse loaded data)?


If you use the standard actions to save data, the data will be saved in the webbrowser webstorage which is on the user’s computer. So you can keep the same name, you don’t have to care where the storage is done. :wink:

Thanks Victor! To save a game it’s ok. Understood and tested!

But something goes wrong when “loading” data from xml or json.
I am testing loading data just to change “language options” on load game.

I did another test project with the two options:

  1. load json data from selfhost
  2. load xml from local xml

Both works perfectly when I preview from “native game”, and none of then works when i preview from “HTML5” project.

The HTML5 project is storage on : rizomatico.org/testegame2/

Here are the screenshots of events and host structure:

A) Events:

B) The host structure:

No, the save/load actions of HTML5 use webstorages which are not the content of the website. The webstorages is a small storage in the webbrowser, not in your website. So, you can’t load a file from your website using those actions.

Ok, got it!

P.S. : but it would be a nice trick to load data from files for multi language content translation.

You should be able to launch a request (an HTTP GET request for example) to get the data into a variable (there is an action to launch a request).

Yes, but that was I’ve already did in the example above.

I’ve used request from web, with a json file; and than parsed to a variable.

It had worked with local file, but not with the project uploaded. But, no problem. I’ll do it inside the game.

You speak about the first action of the screenshot ? It should work in both cases because you download the file from your website even when previewing locally. But I can’t see the whole action in your screenshot because of the panel in front of it.

EDIT : what does VariableString("") mean ? (First action)

Better than I try to explain, these are new screenshots and source files:

Here, the events editor:

Here, the json requested:

Here, the Json parse file to a variable:

And here, the source files:
mediafire.com/download/1ygd4 … ico.tar.gz

Here the FTP Login and password for tests:

host: www.rizomatico.org
user: tests@rizomatico.org

I see one problem :


means the content of the variable “” (and it’s not a valid variable name).
Just use “” instead if you want that parameter to be an empty string.

Yes, it was wrong. I’ve changed and tested again, reading step by step the wiki page about json file load.
Again, it works beautiful for a native game preview, but for html5 (as you can see following the url ) nothing apears. Very strange.

I’ve tested with local parameters( without filling in the full url), as mentioned in the wiki, and again, filling in the full url to the file. Both ways works for a native game, but none of then to the html5 version.

I do not know if others have already tested or used this resource, but I really tried a lot, with many different options.

I’ve found the problem. JS request can only be done on url from the same server (if not, the request is rejected).
So, to make it work, you should try to remove the first parameter from your request (the server will be the current one).
The problem is that it won’t work when previewing but only when testing on the real server.

(Currently investigating how to do cross-domain requests)

The problem is on the server’s side.
You need to add some lines to your server’s .htaccess file :

Header add Access-Control-Allow-Origin "*" Header add Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT"
(You can add this to the root .htaccess or to the testegame2 folder’s .htaccess)

PS : With that, you don’t need to remove your domain from the request in GD (it will work when previewing).

EDIT : Use add instead of set in .htaccess

Hey Victor!

Look at there! (rizomatico.org/testegame2/ )Works!
Thanks a lot for that! That’s the way to my multiple language and dialog system!!!