[High scores] How to check if disconnected from server?
Good Evening! I hope you are having a wonderful day!
I am currently only using the High Score functionality for guests only. Is there any particular way to check easily if the player has no internet connection (i.e., is not connected to the server)?
Right now I have a variable called connected in my GMS object that gets updated with an alarm[0] event that checks if it is connected and if not, it reconnects to the server:
connected=gms_info_isconnected();
if(!connected){
//show_message("connect me");
gms_connect();
}
alarm[0]=rate;
I have been doing some tests and when I try to add a guest to the high score several times while I am not connected, when the Internet connection returns (and this code reconnects the game to the server) it will not add any new guest entries I add afterwards. So I guess I have a question:
How can I check easily if the high score was not sent? I tried using in my callback if(result!= e_ok) like in the example but it won't show my error message.
Replies (2)
Last message on 9 Jul 2016
Size43
(Administrator)
on
9 Jul 2016, 21:19:03
If you get a callback (there might be some cases in which you don't get one, for example being disconnected while sending the highscore). You could add a timer to check if the callback is called before the timer exceeds some timeout value, for example 2 seconds.
If the callback is called and result == e_ok, you can be sure that the score has been added. Note that it might take a few more seconds before the highscores are updated in-game.
Perfect, thank you very much. That answers it perfectly! I'll give that a try.