• 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!

Saving and Loading in html 5 browergame

M

matzematic28

Guest
hi guys im currently making a browsergame and im wondering if it is possible for players to save and load their game online
 

Mert

Member
You can write to browser's local storage. The data will stay there even if the player closes the browser.

Code:
web_local_storage_set("Nickname","Marty");
web_local_storage_set("Level","10");
web_local_storage_set("Gold","250");
Get the data from local storage
Code:
var nickname = web_local_storage_get("Nickname");
draw_text(20,20,"His nickname is : "+string(nickname));
You can set a cookie as well.
Code:
web_cookie_set("LoggedIn","TRUE", 3600);
//In 1 hour(3600 seconds), this will be removed
Here's the extension : https://gmdevblog.com/game-maker-web-local-session-storage-cookies-extension/
 
M

matzematic28

Guest
You can write to browser's local storage. The data will stay there even if the player closes the browser.

Code:
web_local_storage_set("Nickname","Marty");
web_local_storage_set("Level","10");
web_local_storage_set("Gold","250");
Get the data from local storage
Code:
var nickname = web_local_storage_get("Nickname");
draw_text(20,20,"His nickname is : "+string(nickname));
You can set a cookie as well.
Code:
web_cookie_set("LoggedIn","TRUE", 3600);
//In 1 hour(3600 seconds), this will be removed
Here's the extension : https://gmdevblog.com/game-maker-web-local-session-storage-cookies-extension/
thank you so much!
 
Top