On-line ScoreBoard [Not maintained .. new extension available ]

mdotedot

  • Posts: 1654


A new version that works internally like other multiplayer extensions:

http://community.stencyl.com/index.php/topic,42216.0.html











There is a free website that currently hosts a system where you can obtain
Application ID and ScoreBoard ID to use as your online high/low-score board.

Tested: iOS, Android, native Windows, native OSX and Flash (Browser)

I’m not guaranteeing that this website will be up or that the stored data is save!

Using this extension is at your own risk!

Why I made this extension?
Parse.com has limitations on protocols.
Nuggeta says it is moving away from cloud service.
To have greater control I wanted my own server.

Future extensions should include on-line database creation, Lobby-server, Turnbased system and inventory system.
Planned is also an UDP Socket server but this will not run on this free website.

You can download the complete PHP/MySQL sources from the website to run your own server. Instructions: README.TXT inside the tar-ball.

Download the ScoreBoard Extension: http://mdotedot.net78.net/stencyl/ScoreBoard.zip

Get your own Application ID and StoreID :

Server: http://mdotedot.net78.net/stencyl/index.php  








Please check your Junk mail if you don’t receive it in your regular Inbox.

Install the Extension
Go to Settings -> Extensions
[Install Extension]
Open the downloaded ScoreBoard.zip
Close and reopen your game

Now you should have the blocks:




Connect to the server with URL: http://mdotedot.net78.net/stencyl/stencyl.php
You have to give your AppID and StoreID that have been sent to your email address once you applied for them.


AppID is the key that you use to reference the ScoreBoard.
You supply a level, even if you don’t use levels in your game (use 1)
Type: Number, Time or Text. You can store these types as value-type.
Score: the value that you want to store.

The wrapper block is used because it takes time to store the data on the server and you have to know if it is stored or not.
The blocks you put inside the wrapper will be called if the storage is done.


With this block you can get the data from the server.
We already discussed AppID, Level, Type.
Rows and the order should be fairly obvious.

The ID is something special.
We need to track the request because the data is taking a long time and you don’t know how long it takes.
That is why there is a wrapper block. The data is available INSIDE the wrapper and then you need to use the ID
supplied to get a pointer to the data.


The previous block is used to get a high/low score list depending on the order. What if you want to
know the score of a player? Then you have this block.
There is only one (type-)value possible for one player. So if you want to know what the stored score is you can retrieve it using this block.


This is the block with which you can get all the data that you requested with one of the request blocks.
Each row contains a list with two values: the players name and the score.
If you need different lists containing only the names and only the scores you can use the following blocks:


The ID used in these blocks refer back to the IDs from the Request blocks!!

Example:



Best regards from
M.E.

P.S. Thanks to SadiQ for Beta-testing!

Updated:
2015-02-18
*  Modified ScoreBoard.hx to make sure that the URL is not cached
* Block : [Get position on scoreboard for id [ 0 ] Order: [asc/desc] ] to get the position on the list INSIDE request score from playername
* Block: [Get number of rows on scoreboard for ID: [ 0 ] ]  to get the number of rows that make up the scoreboard (inside request)

« Last Edit: July 09, 2015, 04:37:11 am by mdotedot »
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

Justin

  • *
  • Posts: 4716
This is a really neat idea. Thanks for putting your time into this!
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

WarrenTierney

  • Posts: 13
This is a super cool idea, I am definietly going to try it out. On a related note is it possible to upload a game online (server a), and save the game attributes to a different server (server b)? I have a  php file linking the database to the server (server b)and I have also a crossdomain file allowing accessing from server a to server b. I was thinking if I created a form and had congruence between all the forms it might work. For instance, the name:John&password:12345 example. Is it possible to put score and have a score filed on the php and then transfer this to a database? Or are there easier ways to do this like using Newgrounds as a server/database?

mdotedot

  • Posts: 1654
Thanks for the feedback!

@WarrenTierney:
It doesn't matter where the source is coming from. If you 'run' your game from server A you can save the data on server B.
The way that it works from a browser perspective is that you download the code, run it in your computer and your computer connects to server B.
I was able to publish the example on Stencyl Arcade which is in fact a different computer then the computer where the PHP/MySQL stuff is on.

I have no experience and desire to use Newgrounds as a server, so I can't give you information on how they work.

Best regards from
M.E.
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

WarrenTierney

  • Posts: 13
Thanks for your reply man, and please excuse me for my ignorance but how can I do it?

For instance, I have a game attribute, which is saving and working. Then I use the post function to set-up to post to my php file on my website. Now I have made a cross-domain.xml in root folder of server allowing full permission for survey. I see from the logs that the website has made a Get request, but it does not post the information. I think the problem is I have a submit set up on the php file. I know this is silly but I am super new to all this stuff and I appreciate the POST function on Stencyl does not probably press the submit button :P.

So I was just wondering is what I am trying to do possible? And if it is my logic correct i.e.., create game with scoring system, upload game on Qualtrics,  set the game attributes to post to my server, access this information.

That is all I need to do. Anyway any advice anyone could offer would be great, I am super hyped about creating a game but makes me sad to think I may not be able to do it!

mdotedot

  • Posts: 1654
The extension uses the equivalent of 'visit URL' block from Stencyl.
In the PHP code I do a $_GET['argument'] to get the data that has been send from Stencyl.
You are free to download the .tar file containing all the sources to see how I made the PHP/MySQL combination.
Or you could try the extension first to see how it works for you.

Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

WarrenTierney

  • Posts: 13
Again sorry for Trolling your page.

I have the mysql functioning with get and post on two different php pages. Both connected to the same mysql database, and when I submit, and add information to the link, both register on MySql, however when I try via Qualtrics, which is the website I have uploaded the game, it does not work. Even to be highly conservative I used the visit block to try the GET method. Either way doesnt work. It appears to be the link between Stencyl and webpage. I have created a crossdomain file so interesting that nothing comes up. Strange thing is yesterday I could clearly see the game on qualtrics sending a Get request to my website. Might be the security settings on Flash, or I may broaden the crossdomain file to allow every page from Qualtrics.  If I try the visit block as a test on my server this will show whether it is Stencyl or Qualtrics.  I am just putting this out there in order to help anyone. Not that I know what I am doing. I only started using Stencyl Thursday and I have zero programming experience. Sorry for trolling man!

mdotedot

  • Posts: 1654
Hello Warren,

Visit block with GET should work, that is what I use.
I'm not too familiar with broadening crossdomain file.  The .tar file contains the xml file that I have used with my tests that even included the Stencyl Arcade so it works with both my personal web-site, aracde and another site.

Hope it helps anyway!

Best regards from
M.E.
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

WarrenTierney

  • Posts: 13
Thanks man, I actually figured it out, I can now send Game Attributes to server! I am just going to write a entry about it once I refine the build. It is really simple! This along with your save scoreboard function could be really cool,  you could essentially have a game which automatically enters you into a database and then you could retrieve your score.

Joraanpe

  • Posts: 287
Testing it right now with the flash side, works perfect, thanks!
Just have a couple questions, im targeting to work with mobile...

*What would happen if the user requests the Highscore table but do not have net connection?

*Is there any way i can allow users create their own User Nickname or so? I can't make them keep the fixed one i added on the blocks

*And also I've noted during my tests that most of the time it takes several seconds to get the reply from the server and display the scores, is there any reason? Could there be any ways to make it "faster"?  Its not like if it was a problem, but im afraid that the customer would not know there is a highscore table coming from a server, and does something else like switching the scene, in place of waiting for the table result displaying..

Thanks again mdotedot awesome job!

« Last Edit: December 16, 2014, 06:33:34 pm by Joraanpe »

mdotedot

  • Posts: 1654
Hello Joraanpe,

Thank you for your feedback!


*What would happen if the user requests the Highscore table but do not have net connection?
Nothing :)
But seriously, I should make a block for checking on that!
You could do a check yourself. Using the 'visit URL' block in Stencyl. Put a boolean attribute with name connected to false before the block and inside the visit-block set the boolean connected to true.
The URL to visit could be anything.


*Is there any way i can allow users create their own User Nickname or so? I can't make them keep the fixed one i added on the blocks

You can use the TextField behaviour from StencylForge so you have user-input.



*And also I've noted during my tests that most of the time it takes several seconds to get the reply from the server and display the scores, is there any reason? Could there be any ways to make it "faster"?  Its not like if it was a problem, but im afraid that the customer would not know there is a highscore table coming from a server, and does something else like switching the scene, in place of waiting for the table result displaying..

The reason could be many. The server is a free website which doesn't guarantee up-time and high-speed quality. But anything on the internet can be slow. All those hops before it reaches either end.
Again you could use an attribute set to false before the highscore retrieval and have a drawing event that displays 'loading highscore' text on screen while it retrieves the data and the attribute == false. Once you have the list-data you set that attribute to true and the draw event stops drawing loading-text.


Hope this helps!

Best regards from
M.E.
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

Joraanpe

  • Posts: 287
Hello Joraanpe,

Thank you for your feedback!

Best regards from
M.E.

Thanks a lot for such a complete reply and help mate!
Just wanted to ask you couple extra things:

*The TextField behaviour is awesome, it really does the trick over the android keyboard issue!
I have added the GA to hold the player nick name, but im having a doubt about where to set the save block, since adding it at the drawing wrapper just collapses the memory usage hehe. It would be cool to set it "somewhere" where it can recognise if the keyboard was closed or you ended typing.... But im not totally sure how your code works in fact to catch that spot myself
Also, im wondering if there is any way to limit the user the amount of characters he can use, so they don't add a long name.

Again, thanks a lot for your help and time!!

mdotedot

  • Posts: 1654
Hello Joraanpe,

You are welcome!

What I do is to have the input on one actor and a 'OK' button which does the store in a Game Attribute and I do a switch scene to start my game.

I did actually had such a function in limiting the number of characters, but I found it frustrating for my use-cases.
You are allowed to modify the behavior to fit your need.

In the created event is this code block:
 
Code: [Select]
Engine.stage.addEventListener(nme.events.KeyboardEvent.KEY_DOWN, function(event:nme.events.KeyboardEvent):Void{

 
In this code block you can add an if-code to check if the length of text exceeds an attribute.

Suppose you would make a attribute 'maxLength', then you can reference this attribute using _maxLength inside the code block.

Modify the code to read:
Code: [Select]
      if(_isFocus && code > 27 && actor.getActorValue("Value").length < _maxLength){

Hope this helps!

Best regards from
M.E.
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

Joraanpe

  • Posts: 287
Hello Joraanpe,

You are welcome!

What I do is to have the input on one actor and a 'OK' button which does the store in a Game Attribute and I do a switch scene to start my game.

I did actually had such a function in limiting the number of characters, but I found it frustrating for my use-cases.
You are allowed to modify the behavior to fit your need.

In the created event is this code block:
 
Code: [Select]
Engine.stage.addEventListener(nme.events.KeyboardEvent.KEY_DOWN, function(event:nme.events.KeyboardEvent):Void{

 
In this code block you can add an if-code to check if the length of text exceeds an attribute.

Suppose you would make a attribute 'maxLength', then you can reference this attribute using _maxLength inside the code block.

Modify the code to read:
Code: [Select]
      if(_isFocus && code > 27 && actor.getActorValue("Value").length < _maxLength){

Hope this helps!

Best regards from
M.E.

Sweettttt!!! Finally gotcha!! Thanks a lot mate!
Im about to finish my game (my first app ever!) and publish it. Just wanted to make a small detail to you and another friend that have importantly helped me with this project. Let me know if your nick is fine or if you prefer your rl name :)

Thanks again!


mdotedot

  • Posts: 1654
Glad you sorted it out!
No credit due, but if you want you can put M.E. or MdotEdot in the credits!

Hope your game does well!

Best regards from
M.E.
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.