Page 1 of 1

Online Leaderboard

Posted: Sun Feb 23, 2014 4:15 pm
by mattrgs
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

Re: Online Leaderboard

Posted: Sun Feb 23, 2014 6:42 pm
by qberty1337
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.

Re: Online Leaderboard

Posted: Sun Feb 23, 2014 8:00 pm
by mattrgs
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

Re: Online Leaderboard

Posted: Sun Feb 23, 2014 9:13 pm
by ChrisMukrow
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

Re: Online Leaderboard

Posted: Mon Feb 24, 2014 12:59 am
by Simon
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

Re: Online Leaderboard

Posted: Mon Feb 24, 2014 9:54 am
by mattrgs
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

Re: Online Leaderboard

Posted: Mon Feb 24, 2014 1:06 pm
by mattrgs
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.

Re: Online Leaderboard

Posted: Mon Feb 24, 2014 11:39 pm
by Simon
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