WebAPI for Game Maker Studio
A downloadable asset pack
This is a WebAPI that allow you to create a online user database for your game (backend). Setup buttons will create the tables and fields in your mysql database on your webserver (homepage). The players can register, validate their email and login with this API. You can also save data to the database and load it cross platforms. Ex the user save data in your game on an android device and then load the data on the PC version of your game. Users can also upload files.
Works on GMS1.4 and GMS2. Should work on all platforms. Note that in GMS2 the demo only works on Windows target due to the deprecated "get_string" function.
New feature: Global variable save. Can be used to save attempts and win counters for games. If a player try a level you can count up a value +1. When a player win a level you can count up another value +1. Then you can grab the try value ex say the level has been played 10000 times worldwide but only 1000 has finish it. This means your level have a success rate of 1000/10000=10% of the total players worldwide. You can then see how difficult the level was worldwide.
You can have unlimited amount of rows and 30 counters in each row for you to play around with.
Here is a complete list of features:
- List high-score
- High-score count entities
- Load user share data (user can share data with each other)
- Get active users (check how may is "online" and playing your game right now)
- Get total users count
- Download files (http_get_file)
- Get external IP
- Save global var
- Load global var
- Get user list
- Get UTC time
- Load public var (for public quests and messages)
- Register with email validation
- Forgot password reset email
- Delete user account
- Save user data
- Load user data
- Save high-score
- Load high-score (get points and rank)
- Change password
- Change username
- Save share data (for the public)
- Upload files
- Upload files via web browser
- Check if file (ex uploaded file) exists on server
- Server curl upload (web-server to web-server upload)
- Ordinary web-server (homepage) space with a PHP version 5.6 or above.
- mysql 5.5 database or above on your web-server (homepage).
"1. Is the transfer safe? Or is it easy to catch it, eg by a wifi catcher?"
If you use "https" it should be safe. Set it in:
Make sure your webhost support https.
You can also try encrypt the data yourself before sending it. And then de-encrypt it when you download it.
"2. I want to save some data in several ds_lists. eg the character points, in a ds_grid his items and other things. can I still make several slots? save003 save004 etc? and how?"
Right now there is only 2 slots in the database. But each slot can hold 4GB of data. So you could create a map chunk with all the data and slots.
// Create a map that hold the data chunk
var j_map = ds_map_create();
// Create a list that can hold quests
var j_list = ds_list_create();
// Create a map that can hold inventory
var sub_map = ds_map_create();
// Add the quest list to the head map
ds_map_add_list(j_map, "Quests", j_list);
// Add the inventory map to the head map
ds_map_add_map(j_map, "Inventory", sub_map);
var j = json_encode(j_map);
The j var is now a string that you can send to the server with all the data.
"can I read the status points from other players? For example, I want a player attack the player"
There are two things you can try:
Shared data:With "scr_webapi_save_share" you can save data that other can get with scr_webapi_load_share.
So you can save some status data in the shared slot.
Note that the other users need the shared token (a string) in order to use scr_webapi_load_share.
Each player get the shared token when they login:
scr_webapi_Login_Done>show_debug_message("Share token:" + string(result_map[? "share_token"]));
So you need to share this string to the other players somehow. Like some kind of friend list.
You can create a "placeholder account". Create a new account with a hard coded email and password. Let the user login to his account. Grab his shared token. The player could then temporarily login to this system user and get or save system data, like their shared token string. Then each user could get a full list of all users shared tokens. Then the user can login back to his personal account.
Global var save:Glabal var save is a system where anyone can save and get numeric data.
You have unlimited rows and 30 columns that anyone can use.
In your case you can use one row for each player and store 30 numeric variables in each column.
To know what row each player is in you can use the database index:
scr_webapi_Login_Done>show_debug_message("DB index:" + string(result_map[? "db_id"]));
This is a unique number for each user that login and it will always be the same, even if the user logout and login again later.
So say your player add 30 in hp we can save that data with:
This will add 30 to the column on row db_index, not set it. So use load obj_load_var to check the current value first. But the best is to design your game to add or remove values.
Now say P2 want to attack you. He can call:
This will do a -3 to the earlier added 30 so it will be on 27 then.
Note that this means the other player need the db index. You can simple check a db index with obj_load_var and use a column as some kind of current status.
In order to download this asset pack you must purchase it at or above the minimum price of $9.99 USD. You will get access to the following files:
- WebAPI 1.2.3Jul 04, 2019
- WebAPI Update 1.2.2May 17, 2019
- WebAPI 1.2.1 UpdateApr 18, 2018
- WebAPI Bugfix update 1.2.0Feb 05, 2018
- WebAPI Bugfix update 1.1.8Feb 03, 2018
- WebAPI Bugfix update 1.1.7Jan 30, 2018
- WebAPI Bugfix updateDec 19, 2017
- WebAPI Global counter variablesNov 23, 2017