How to check if the player is logged in Google Play Games?

Get help using Construct 2

Post » Mon Jun 16, 2014 5:29 pm

I've integrated Google Play Game Services in my game. I've put a login button and leaderboard & achievement buttons. I've coded it so that only when CocoonJS -> On Login Succeeded then leaderboard and achievement buttons are enabled. The problem is that suppose a player logs into Google Play Game Services, now leaderboard and achievement buttons are enabled. Now he quits the game and re-opens it. He is already logged into the game (Welcome XYZ appears at the time of ludei splashscreen), but inside the game, the leaderboard and achievement buttons are disabled because It could not detect that player is already logged in. So, the player has to click the LOGIN button. Then, the other buttons are unlocked.

I tried to do this:
On start of layout: CocoonJS -> On Login Succeeded: Set global variable "loggedIn" to 1. If loggedIn is 1 then enable leaderboard and achievement buttons.

But it is not working. Any help?

Thanks
B
10
S
2
Posts: 79
Reputation: 1,122

Post » Wed Jul 23, 2014 10:48 am

It is a shame they don't have this condition added already. I don't even know any javascript and I was able to fix the problem. You'll need to modify the cocoonjs 'edittime.js' and 'runtime.js' files. I looked at putting it on the ludei/cocoonjs github page but I can't figure the damn thing out and have no patience for it...

I will post some screenshots of what you gotta do. It's not much. Just keep in mind that if you ever install an updated version of C2 or cocoonjs plugin, you will have to add the lines again or you could have issues. And make sure to back up the original edittime.js and runtime.js files before you tinker.
B
7
S
1
Posts: 25
Reputation: 477

Post » Wed Jul 23, 2014 11:51 am

Just a reminder: since you are going to be editing some javascript files here, if you ever update C2 or the CocoonJS plugin, you will have to make these same edits again (or end up suffering from issues/bugs).

Step 1: Navigate to the cocoonjs plugin folder (should be at --> C:\Program Files\Construct 2\exporters\html5\plugins\cocoonjsads)

Step 2: Make backup copies of both edittime.js and runtime.js.

Step 3: Open edittime.js and runtime.js (I use dreamweaver, but you can also use notepad).

Step 4: Follow the pictures below (the lines of code are in bold below the pics for an easy copy/paste).

edittime.png

AddCondition(31, 0, "Is Signed In", "Social", "Is Signed In", "True if the user is currently logged into the Google Play.", "isSignedIn");

runtime.png

this.isSignedIn = false;

Cnds.prototype.isSignedIn = function ()
{
if (this.socialServiceInterface.isLoggedIn())
return true;
else
return false;
};


self.runtime.trigger(cr.plugins_.CJSAds.prototype.cnds.isSignedIn, self);

1.png


I hope this makes sense. You may have to make another copy of the 2 files onto your desktop and edit the files from there (in my case I cannot make edits directly from the cocoonjsads folder).
You do not have the required permissions to view the files attached to this post.
B
7
S
1
Posts: 25
Reputation: 477

Post » Mon Dec 08, 2014 5:27 pm

Hey ! I saw that you have a working Google play leaderboard exported using cocoonjs right ? I am facing problem with Leaderboard, it doesn't show up on my Apk. It only makes login, i can't submit or retrieve highscore. Any help will be appreciated. Ciao !
B
9
S
1
Posts: 61
Reputation: 584

Post » Thu Dec 11, 2014 8:32 pm

I Got my problem Fixed ! it was something in the developer console ;)
B
9
S
1
Posts: 61
Reputation: 584


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 18 guests