I am going to build a real time multiplayer game for android. I'm planning to use Google Play Games Service https://developers.google.com/games/services/android/realtimeMultiplayer
I understand, that I can use Leaderboard to save main player stat, for example Wins. But I need to be able to implement a way to store more information about the player. For example wins, losses, inventory and etc. So when two players join game room, before the start they could see each other's information.
I wonder where this information should be saved so that when two players connect to the same game room, they can see each others data. If it is saved on client's device, I guess it is a risk that a cheater can upgrade his own stats somehow, am I right?
What is the best practice? Thank you.
Related
I am working on an android game(which is created using Unity3d engine) and I was trying to use google game service features when I stumbled upon a question implementing leaderboards.
Is there any way to sort player scores based on their location?
I want players to know their rank in their country, continent, etc. Something like google's time based leaderboards(daily, weekly and monthly)
Do I have to implement this feature myself? If so leave your thoughts and ideas.
Creating your own leaderboard means you have to write a Server (i.e. a HTTP Server) that can store the players, the scores and the locations (preferably in a database).
Getting the location of your users depends on the final build (browser, app, windows exe, etc.)
The Google Play Games Services guidelines state the following: "After signing in, the player must always have the option to sign out."
Imagine the following scenario:
I download a mobile game and play it for a few weeks whilst authenticated
During this time, I unlock levels and accumulate in-game currency (which is saved to the cloud)
I decide to sign out of Google Play Games Services, but continue playing the game
I see two options for managing the player's data:
1. Copy all of their cloud-saved data to local device storage
2. Start the user over again, saving data to local storage (if they log back in, they'll get access to their cloud save data again)
The first option sounds the most logical, but it also means if the user logs back in again that I'd sync the local data back to the cloud. Therefore, a user could sign out, alter the locally-stored preferences on their device directly (e.g. add 1000000 coins), then sign back in and have that data synced.
My question is, is synchronising the data both ways the "correct" way to go about this, despite the risk of (some) players being able to tamper with their data? I've been able to find plenty of info about signing out, but not what to do afterwards.
Thanks!
My question is, is synchronising the data both ways the "correct" way
to go about this, despite the risk of (some) players being able to
tamper with their data?
Nope. Separate the score system into two:
Offline and online score.
When user sign-out, take the online score and save it to the offline score. User's offline score will continue from where user left from online score.
If you decide to sign in again, use the online score. Also update their offline score with the online score.
By doing this, you are only making it harder for players modify score. If the game is running on the player's side, the player can always change the score if they understand basic APK reverse-engineering. The data does not have to be saved in other to be altered. It can be changed in the memory. It can also be changed by decompiling, altering your code,compiling and signing the APK.
Now, if you make the game to run on the server but read input from the user then it cannot be altered unless your server is hacked.
This depends on the game if it is a story based game you could solve this issue by differentiating between authentic cloud saves and offline saves with a save menu as you are not limited to one save by the API. If it is a premium currency based game such 1.00$ for 100 Gems you should keep all transaction records on the server as it is not wise to allow the user any chance to alter these values.
"A game can write an arbitrary number of Saved Games for a single player, subject to user quota, so there is no hard requirement to restrict players to a single save file. ... All Saved Games are stored in your players' Google Drive Application Data Folder. This folder can only be read and written by your game - it cannot be viewed or modified by other developers’ games, so there is additional protection against data corruption. ... Saved Games are insulated from direct tampering by players so they cannot modify individual Saved Games. ... In general, the best way to avoid data conflicts is to always load the latest data from the service when your application starts up or resumes, and save data to the service with reasonable frequency. ... Your application should make every effort to handle conflicts such that your users' data is preserved and that they have a good experience."
here is a link with more information.
Sorry if my question is asinine.
I'd like to send the data in SQL table format from one Android device to a second device, so the user in the second device can store and use the received data with my App. What are the best options to do this?
You don't want to go down the path of trying to move one sqlite file on a device into the same location on another (I assume that's where you were going with the Bluetooth tag). Without root access on the destination device, you won't be able to write the file. From an end (power) user perspective, Titanium Backup is a great solution for this, but of course requires root.
If you're looking for "stop on one device, resume on another" functionality for your app, check out Google Play Services Saved Games. It has exactly the functionality you're looking for baked in, and you have to do nothing along the lines of the support infrastructure.
Of course, this is dependent on Google Play Services, so if you're looking to publish on the Amazon App Store (or anything where you're not guaranteed to have the Google stuff available), you may be better off rolling your own web based synchronization infrastructure or subscribing to a service that offers something on par with what Google makes available.
I can only imagine there must be a way for me to invoke some kind of GUI that will show all the matches a player has going on, whose turn it is, who they're playing etc. Is there such a GUI call for Google Play Game Services or do I really need to work this all out manually by loading matches and created my own GUI from the data? It's proving to be a lot of work and I feel like it just HAS to be wasted effort. Game Center has it...
From Developing a Turn-based Multiplayer Game in Android found in the Google Play Game Services docs.
Once a player has signed in to your game, the player may receive invitations to join a turn-based match created by another player. To save coding time and provide users with a consistent UI for responding to match invitations across applications, you can use the default match inbox UI provided by the SDK. To launch the default match inbox UI, call getInboxIntent() to get an Intent; then call startActivityForResult() and pass in that Intent.
It appears there is a built in GUI. I don't have an app to try it out but you can get more information here I hope that helps.
im trying to develop a multiplayer game using google play game service.
In my game i have some game logic that will run only one players set ,which i prefr to call host.
i would like to determine the host by player who created the room.
but i see room creator id can be different in different players set on a single game,and each returns as creator in auto match game.
so what should be the ideal way to find a host ,apart from sorting the player list and use the first participant as host ?
Google provided a video specifically on Google Play Games: Choosing a specific user which explains how to work around agreeing and assigning a specific user a special roll. In summary: sort the participantIds and have the first by sorted order randomly choose the host and broadcast that to the other players. This ensures that all users agree on the host and the host is randomly chosen each time.