Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm currently using the following MySQL example to make a server side high score table: Unity Server Side high score

The above example allows me to create a top 5 player high score table that sorts itself based on the score amount. However, my knowledge of PHP and MySQL is limited to only that of the above example and I wish to expand upon it.

What I now want to do is create a local score amount (the score the player accumulates during game play) that is updated on my server. At the moment, the server only calls the total scores once, and I want it to be polled so that it updates the moment the player earns some points. And displays this score.

The reason for this, is because my high score, and local score, are going to be displayed on another device. Say your playing my game on a PC but the score is updating and showing you on an iPad (rubbish example, but you get the idea).

Can anyone point me in the right direction as to how I would go about doing this, using the example I've already used?

share|improve this question
    
Dont give 100 dislikes.. But my solution would be to use a complete hiscore solution. There are plenty over the unity asset store. Unless you want to make the solution to the problem itself. Check this out design3.com/training-center/engines-sdks/unity/coding/… –  Mikolaj Marcisz Apr 9 '13 at 12:36
add comment

1 Answer

You can implement a function that will run as a callback when the player's score changes, this function can open a socket and send the required data to the server. I don't think it is necessary to do this asynchronously since the player's score is usually an integer (4 bytes) so sending it to the server won't be a great deal (along with the bytes of the protocol you are using, if you are using one).

The only case you need to do it in async is when there are lots of people sending data simultaneously and your server doesn't have enough unused connections to accept another incoming request, thus blocking the client (your game).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.