Can we send request "unlock achievement" right away?

  • -> GooglePlay: Unlock achievement "xxxxx"

    Is google play plugin/server smart enough to ignore the "Unlock achievement" request which is already unlocked? Or do we need to ask ourselves before making the request?

    The only way the plugin let me do it is the "If GooglePlay: Achievement index is unlocked", although I don't know how to identify the index of the achievements in my play console.

  • The plugin itself doesn't do any checks, as it doesn't keep track of the achievement data. I'm going to describe what the Android version does here, you didn't mention if you were using the web variant or not so I'm going with the more common one. The web one just fires the request off to the server

    Here's the docs for the underlying API the plugin uses AchievementsClient#Unlock

    When you use these methods your basically talking to the Play Games app on that device, which decides what it needs to send to the server and when. Generally it tries really hard to avoid talking to the server, and will show you local copies of the data instead. It's the same in reverse, so it won't send changes until it has to. The API has some methods to force it to sync ( anything with the "Immediate" label will force a sync of all recent changes ) but we generally try to avoid these.

    I expect the app is sensible enough that if you call unlock with something that's already unlocked it won't actually do anything. However, the documentation doesn't say if it does or doesn't. You should probably just test it. When you open the achievement dialog it will normally pause slightly as it opens to sync if it needs to, but will be nearly instant if it doesn't.

  • Nepeo

    Thanks, buddy. I'm about to test it indeed.

    Would you know how to identify the index of each achievement in play console?

    edit: I also have question about the frequency of requests. In my game, I can score in a frequency of up to 1 second or so. My question is if I can save it, submit the score, check and unlock achievement(if is the case) so often. Right now I'm doing it only when the game ends but, every time the player scores, I'm sending a message saying he unlocked a new item or an achievement. Although, If happens something between this moment and the game over (It's an endless game), like crashes or no internet connection, It won't count. The game will be saved because It's saved locally right away and further synced to google's servers, but the score submission and the achievement unlocked won't count. So the player will have an incompatibility situation which the score required is enough but he won't have the achievements matched.

  • Internally there is an array of achievements which you can reference by index. It's just the order from the achievement buffer object. It could be alphabetic or sorted by when you created it. I'm not sure how they decide. There's an expression for getting the ID from an index, you can use this to create a lookup dictionary. The only reason why it works by ID is compatability with the older C2 version of the plugin and the web API, we actually have an internal map of ID to achievement which could easily be accessed by an expression. But then we'd have to duplicate the expressions, and that gets a bit messy... I might bring it up with Ash, see what we can come up with.

    In terms of your other question, if your offline the Play games service still works I believe. It will deal with syncing unlocked achievements and leaderboards when the device is reconnected. I wouldn't be surprised if it still told the user when the achievement was unlocked, even without network, provided it had already synced the initial achievement data.

    By the sounds of it your doing some sort of "if ( userscore > achievementThreshold ) then unlockAchievement" you can substitute this for the Steps style achievements so that you don't have to save the user score somewhere. The steps style requires you to set a target value in the console, then you can interact through 2 actions SetSteps and IncrementSteps. Increment adds to the current counter ( useful for "user has played x many games" ) and SetSteps sets the remote value ( useful for "user has scored higher than" ). Again all this stuff is controlled and synced by Play Games without you having to worry about internet.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Well, If It all works offline first and synced later I believe saving the game as well as submitting to leaderboard and checking for achievements every 1 second or so won't be a problem then. Better this way so the message by google's service will appear right after the achievement is actually unlocked.

    Thanks for the explanation, Nepeo

    Edit: Sorry to bother you again Nepeo but Could you stop by in this Topic about custom splash screen?

    construct.net/en/forum/construct-3/how-do-i-8/do-custom-splash-screen-131546

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)