Untitled Document
 
HOME
DOCUMENTATION
PRICING
FORUM
CONTACT
GMDB
LEADERBOARDS AND SERVICES FOR GAMEMAKER
Untitled Document
00

DOCUMENTATION AND USAGE

Follow our easy step by step to implement our services into your Gamemaker Studio projects.
01

LEADERBOARD AND SCORES

1. Register for a free account if you have not already done so.
Registering for a free account with GMDB opens a range of back end services for your Gamemaker Studio projects.
2. Create a new Leaderboard
Choose a leaderboard name and click create leaderboard. This will generate a new leaderboard string that we will use later to insert a score into your database.
3. Submit a score to your leaderboard.
Submit a score to your leaderboard using the http_post_string() function as follows.
dataSource = "leaderboardString=UNIQUE-LEADERBOARD-STRING&ownerString=UNIQUE-USER-STRING&playerName=PLAYER-NAME&playerScore=PLAYER-SCORE";

submitScore = http_post_string("https://www.gmdb.co.uk/data/insertScore.php", dataSource);
4. To get the basic scores for your leaderboard use the code below.
Retrieve your scores using the following code using the http_post_string() function.
leaderboardData = "leaderboardString=UNIQUE-LEADERBOARD-STRING&ownerString=UNIQUE-USER-STRING";

getLeaderboard = http_post_string("https://www.gmdb.co.uk/data/get_leaderboard.php", leaderboardData);
5. ASYNC Function
Once you have sent the request for the scores you can use the following code to show the scores on your Gamemaker project
The code below is just a basic use of the leaderboard data so can be modified to suit your needs.

if (ds_map_find_value(async_load, "id") == getLeaderboard)
{
if (ds_map_find_value(async_load, "status") == 0)
{

getResult = ds_map_find_value(async_load, "result");
getResultDecoded = json_decode(getResult);

var getAllData = ds_map_find_value(getResultDecoded, "default");

var leaderboardMapSize = ds_list_size(getAllData);

for (var i = 0; i < leaderboardMapSize; i++)
{
leaderboardData = ds_list_find_value(getAllData, i);
global.leaderboardPlayerName[i] = string(ds_map_find_value(leaderboardData, "playerName")); //SAVES PLAY NAME INTO ARRAY
global.leaderboardPlayerScore[i] = string(ds_map_find_value(leaderboardData, "playerScore")); // SAVES PLAYER SCORE INTO ARRAY

//EXTRA VARIABLES
global.leaderboardScoreSubmittedDate[i] = string(ds_map_find_value(leaderboardData, "scoreDate")); // SAVES THE DATE THE SCORE WAS SUBMITTED INTO AN ARRAY AS TIMESTAMP


}

}

5. Need further help?
If you require help to implement the code please get in touch with us at info@gmdb.co.uk

breadcrumb
Untitled Document
TOTAL LEADERBOARDS: 11221 | TOTAL SCORES: 125474 | TOTAL MEMBERS: 548
Untitled Document