Livecode Multiplayer Leaderboard

Creating Games? Developing something for fun?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
FESEFW
Posts: 11
Joined: Sun Sep 06, 2020 4:58 pm

Livecode Multiplayer Leaderboard

Post by FESEFW » Mon Jun 21, 2021 3:01 pm

I am trying to make an online multiplayer leaderboard, I've searched for it all over the internet and I only found one thing that's in the forums and its links doesn't work anymore because it's from 2014.
Please help,
Fest

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Livecode Multiplayer Leaderboard

Post by bogs » Mon Jun 21, 2021 3:43 pm

Hello Fest, could you perhaps give a bit more information about what exactly you are trying to create? For instance, a picture would be helpful, but, lacking that, maybe a short textual form describing what you want as far as looks and functionality go?

The following is an example:

Are you looking for something like this display wise...
Image

Or something more like this....
Image

Or something altogether different?

What information are you looking to display? Does someone need to be logged in to view it? Something else altogether?
Image

FESEFW
Posts: 11
Joined: Sun Sep 06, 2020 4:58 pm

Re: Livecode Multiplayer Leaderboard

Post by FESEFW » Mon Jun 21, 2021 6:03 pm

Hi Bogs,
Thanks for answering so fast,
I am trying to make something like shown in the second picture. I already own a MySQL server that I'm controlling on phpMyAdmin. Also, in the game main screen, I programmed a 'name pick' button which you can pick your name into global _PlayerName.
Thanks,
Fest

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Livecode Multiplayer Leaderboard

Post by bogs » Mon Jun 21, 2021 6:53 pm

Ok, now we have a look your shooting for, while I don't normally recommend this route, it looks like what your shooting for would be a good fit for a form version of a datagrid.

I *think* this lesson should get you started nicely on creating the form style grid you want-
https://lessons.livecode.com/m/datagrid ... -of-people


In your OP you mentioned this would be online, which I am guessing means you store the information online and want the data read back into the application run locally. That part of it (I would hope) some others that do stuff along those lines would chime in for, but I don't foresee any great difficulty in accomplishing it.
Image

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9801
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Livecode Multiplayer Leaderboard

Post by FourthWorld » Mon Jun 21, 2021 7:37 pm

FESEFW wrote:
Mon Jun 21, 2021 3:01 pm
...I only found one thing that's in the forums and its links doesn't work anymore because it's from 2014.
Unlike most languages, LC has an uncommonly good track record of maintaining backward compatibility. Where is that earlier discussion, and what part of it didn't work?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

FESEFW
Posts: 11
Joined: Sun Sep 06, 2020 4:58 pm

Re: Livecode Multiplayer Leaderboard

Post by FESEFW » Tue Jun 22, 2021 6:22 am

bogs wrote:
Mon Jun 21, 2021 6:53 pm

In your OP you mentioned this would be online, which I am guessing means you store the information online and want the data read back into the application run locally. That part of it (I would hope) some others that do stuff along those lines would chime in for, but I don't foresee any great difficulty in accomplishing it.
Thank you so much!

FESEFW
Posts: 11
Joined: Sun Sep 06, 2020 4:58 pm

Re: Livecode Multiplayer Leaderboard

Post by FESEFW » Tue Jun 22, 2021 6:28 am

FourthWorld wrote:
Mon Jun 21, 2021 7:37 pm
FESEFW wrote:
Mon Jun 21, 2021 3:01 pm
...I only found one thing that's in the forums and its links doesn't work anymore because it's from 2014.
Unlike most languages, LC has an uncommonly good track record of maintaining backward compatibility. Where is that earlier discussion, and what part of it didn't work?
For some reason I can't send links

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9801
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Livecode Multiplayer Leaderboard

Post by FourthWorld » Tue Jun 22, 2021 8:06 am

Does it have a title? What section is it in?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

SparkOut
Posts: 2834
Joined: Sun Sep 23, 2007 4:58 pm

Re: Livecode Multiplayer Leaderboard

Post by SparkOut » Tue Jun 22, 2021 9:38 am

Guessing it's this one viewtopic.php?f=22&t=19380#p99792

I'm not sure exactly what you would find in the original stack

ClipArtGuy
Posts: 253
Joined: Wed Aug 19, 2015 4:29 pm

Re: Livecode Multiplayer Leaderboard

Post by ClipArtGuy » Tue Jun 22, 2021 2:45 pm

The high score board of that space shooter stack was powered by a simple mysql database. From my memory it was basically just two columns - name/score.

edit: I'm not exactly sure how helpful this is, but that stack was definitely using a simple mysql database with a table named "highscores" with two columns "name" and "score". I dug this stack out and copied the relevant script, but you should definitely NOT do it this way. It is way more secure to put a script like this on your server as middleware, than to hard code the credentials/functionality into your app itself.

Code: Select all

global AMiConnected
   
   put "yourSQLhosthere" into vScoreDatabaseHost
   put "yourDataBaseNameHere" into vDataBaseName
   put "yourDataBaseUserHere" into vDataBaseUser
   put "yourDataBaseUserPasswordHere" into vDatabasePassword
   put revOpenDatabase("MySQL", vScoreDatabaseHost, vDataBaseName, vDataBaseUser, vDatabasePassword) into tResult
   
   
   if tResult is a number then
      put tResult into AMiConnected
      put "HighScores" into vScoreTable
      put "Name,score" into vNewPlayerInfo
      put fld "score" into vPlayerScore
      put "INSERT INTO " & vScoreTable & " (" & vNewPlayerInfo & ") VALUES (:1, :2)" into tSQL
      revExecuteSQL AMiConnected, tSQL, "vPlayerName", "vPlayerScore"
      put "HighScores" into vScoreTable    
      put "SELECT * FROM " & vScoreTable into tSQL
      put revDataFromQuery(tab, cr, AMiConnected, tSQL) into ScoreData
      if item 1 of ScoreData = "revdberr" then
         answer error "Unable to post high score" 
      else
         put ScoreData into field "Data"
         sort lines of fld "data" descending numeric by word 2 of each
         replace"_" with " " in fld "data"
         repeat with w= 11 to the number of lines in fld "data"
            put empty into line w of fld "data"
         end repeat
         repeat with p=1 to the number of lines in fld "data"
            put (p&".") before line p of fld data
         end repeat
         set the textcolor of line 1 of fld "data" to green
         
      end if
      if AMiConnected is a number then
         revCloseDatabase AMiConnected
         put empty into AMiConnected
      end if
   end if

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9801
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Livecode Multiplayer Leaderboard

Post by FourthWorld » Tue Jun 22, 2021 4:05 pm

Does the leaderboard show the scores of all players, or just the leaders?

If the latter, does it need a database? Might a simple text file do?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

ClipArtGuy
Posts: 253
Joined: Wed Aug 19, 2015 4:29 pm

Re: Livecode Multiplayer Leaderboard

Post by ClipArtGuy » Tue Jun 22, 2021 4:27 pm

FourthWorld wrote:
Tue Jun 22, 2021 4:05 pm
Does the leaderboard show the scores of all players, or just the leaders?

If the latter, does it need a database? Might a simple text file do?
I guess I had assumed that multiplayer leaderboard meant there would potentially be multiple concurrent users (who may try to save their high score) at any given time.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9801
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Livecode Multiplayer Leaderboard

Post by FourthWorld » Tue Jun 22, 2021 5:56 pm

ClipArtGuy wrote:
Tue Jun 22, 2021 4:27 pm
I guess I had assumed that multiplayer leaderboard meant there would potentially be multiple concurrent users (who may try to save their high score) at any given time.
The moment of writing to disk is rarely if ever truly concurrent. The question is how we handle the need to momentarily lock that part of the storage file.

When what's being stored is small, locking the entire file may cost less than a single millisecond.

MySQL's InnoDB storage engine locks at the record level, and its MyISAM engine locks entire tables.

Combined with the overhead of both IAC and LC's externals interface, not to mention the internal b-tree traversal, sometimes locking a small flat file is more efficient.

Little things add up, and using a relational DB engine involves *lots* of little things.

And then there's development and maintenance time...
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

mtalluto
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 125
Joined: Tue Apr 11, 2006 7:02 pm
Location: Seattle, WA
Contact:

Re: Livecode Multiplayer Leaderboard

Post by mtalluto » Wed Jun 30, 2021 12:59 am

Years ago, we made a sample game that demonstrated how to store a player's score and generate a High Score Leaderboard.

The game is written in LiveCode and uses LiveCloud for the backend. The code is simple to read and easy to port to another database.

You can see a quick demo of it on youtube:
https://www.youtube.com/watch?v=wjXHt8MqYNY

Feel free to download the working code here:
https://www.livecloud.io/downloads/Dropper/Dropper.zip

*Please note that this code requires a paid edition of LiveCode because it relies on encryption features found in Indy or Business.

** You do not need a LiveCloud account to play.
Mark Talluto
--
Canela
design - develop - deploy: https://appli.io
Database and Cloud for LiveCode Developers: https://livecloud.io
Company: https://canelasoftware.com

Post Reply

Return to “Games”