Online Leaderboard

The place to discuss anything and everything about running your LiveCode on Android

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
mattrgs
Posts: 37
Joined: Tue May 28, 2013 1:41 pm

Online Leaderboard

Post by mattrgs » Sun Feb 23, 2014 4:15 pm

Hi everyone,
I have been creating a game for Android and I would like to implement a public leaderboard. I was wandering if anyone could offer any suggestions in how to go about this. The ideal one would be to be able to use google play services, as this could then also be used for iOS, however I don't think this is possible with Livecode. So is there an existing service which I could integrate, or alternatively is there a way in which I could set one up for my game. Preferably if I were to use the second option, could it be as simple as possible and also free to maintain.
I would only want to store a username and score so it doesn't need to be too complicated.
Thanks
Matthew

qberty1337
Posts: 35
Joined: Sun Sep 09, 2012 1:09 pm

Re: Online Leaderboard

Post by qberty1337 » Sun Feb 23, 2014 6:42 pm

Well unfortunately the Google Play Services isn't integrated with LiveCode so you can't use any of those free services. I was originally planning on releasing a library stack that would allow easy leaderboards, but that would usually eat up resources (still contemplating on that).

In terms of doing this yourself, a simply method that I use would be to use an SQL database that you manipulate with a web page/API setup.

mattrgs
Posts: 37
Joined: Tue May 28, 2013 1:41 pm

Re: Online Leaderboard

Post by mattrgs » Sun Feb 23, 2014 8:00 pm

Would anyone be willing to provide some guidance on this, as although I am quite proficient in coding I am not confident with databases and webpages etc. Even just to maybe explain the structure of how I should run it, as I don't want to have to overcomplicate my app if it means having to download a lot of data each time a user wants to access it.
Thanks
Matthew

ChrisMukrow
Posts: 73
Joined: Mon Nov 12, 2012 4:13 pm

Re: Online Leaderboard

Post by ChrisMukrow » Sun Feb 23, 2014 9:13 pm

My suggestion for an online leaderboard:

Two pages, submit_score and a leaderboard page. In your app create a post to submit_score with username and score, on the server-side you need to create atleast two other values date and ID (I would recommend PHP, it's pretty easy. If you are going to use PHP please use PDO). And to display the leaderboard make a webview (easier) or parse XML from a webpage and display in app.

Post to server: http://forums.runrev.com/viewtopic.php?f=49&t=10747
PDO: http://www.php.net/manual/en/pdo.connections.php

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Online Leaderboard

Post by Simon » Mon Feb 24, 2014 12:59 am

Hi Matthew,
I'm unclear if you want an updatable in-game leaderboard or a web page that people visit?

Assumption, you actually have a server to read from and write to, in-game results.
Around the openCard (not openStack as the internet library must be loaded first) you download a text file with current leaders

John 2599
Betsy 2030
Mat 7 :(

at the end of a game compare the score with word 2
repeat for each line tLine in highScore
add 1 to i
if i >= 4 then exit repeat
if if myScore > word 2 of tLine then
put myName && myScore into line i of highScore
exit repeat
end if
end repeat
save the file blah blah
post the file to the server
http://forums.runrev.com/phpBB2/viewtop ... =8&t=19144

Yes, with thousands of users there can be collisions (download while someone is uploading), so maybe a mySQL would be better.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

mattrgs
Posts: 37
Joined: Tue May 28, 2013 1:41 pm

Re: Online Leaderboard

Post by mattrgs » Mon Feb 24, 2014 9:54 am

Thanks Simon, to clarify I want a leaderboard which can be updated which appears within the app.
Could you please provide some guidance on how I would do it with SQL, I know there are lessons on how to upload etc. but how would I insert the records, as if it was listed in the correct order on mySQL then surely I might have to sometimes move everything down by 1 row, how?
Thanks
Matthew

mattrgs
Posts: 37
Joined: Tue May 28, 2013 1:41 pm

Re: Online Leaderboard

Post by mattrgs » Mon Feb 24, 2014 1:06 pm

Simon,
I have tested your suggestion just using a field rather than saving the results to a file, however I was hoping to be able to create a leaderboard which contained all entries, not just the top 3. Sorry if I caused confusion.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Online Leaderboard

Post by Simon » Mon Feb 24, 2014 11:39 pm

Hi Matthew,
move everything down by 1 row, how?
Ahh yes, missed thinking of that.

Code: Select all

 put myName && myScore & cr before line 3 of fld 1
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply

Return to “Android Deployment”