How to implement GPGS plugin

Hello!

Thank you for your response. I was wondering where can I get the participant object. Is there a function that returns it?

Sorry for the late response. The listener you attach to gpgs.multiplayer.realtime.sendReliably() will receive a sendReliably event from which you can get the participantID

Just for historical notes on my questions above - I did have to code around the delay between the submitting of the scores to GPGS and getting the listener to fire… a 3 second delay has been enough so far. 

If there was a better way, I was not able to find it.

Sonyallc, I did reply to your request in your other thread.

Hello, in the config.lua file you stated Key, is it the long one with like 50 characters or which key is it, because there are a lot of keys.

thank you

I have followed your thread. As suggested by -schizoid2k, please post some code related to gpgs functionalities. From signing in till leaderboards.show and submission of data to leaderboards.

Note: Check all the id’s are matching with your dev console, and it takes sometimes for the gpgs features to come online after the first  apk using gpgs is uploaded, max 24 hours. 

In the new developer console select the app, then go to Developement_ tools_ - Services & APIs and under Licensing & in-app billing you should see the base-64 RSA public key. That’s the key. 

 

Hi and thank you for your code.
I have a very general question about it.

Is it really necessary to implement hundrets of lines of code to the project just to get GPGS working?
I guess, your code contains every bit of stuff, that could be useful, right?

So I am wondering, what do I really need?

Regards
Christian

PS: Sorry for being the bad guy :wink:
 

Question for you - do you have to make sure the user is logged in before using gpgs.events.increment?  I only want to track some of the usage of various items, I don’t really care about the user info.  Do I still them to login?

Thanks!

To use any gpgs features you need to have user logged in beforehand in every instance of your app.

Roger that, I appreciate the response and thanks for the code above- I am sure it will help a great deal.

Sorry for the very late reply.  

The common code would be the build.settings, config.lua and the sign in/sign up process to gpgs in main.lua and menuScreen.lua. then if you only want leaderboards then just add the leaderboards code part only and so on.

The above code represents, sign in/ sign up to gpgs, leaderboards, achievements, syncing across device via google drive. 
 

The above code has been updated with all the needed modifications. The code may look a bit big at a first glance but once you read through it, you will find it simple as I have tried to use descriptive words and commenting hence very few explanations are given. Hope this updated post helps everyone  :) .

Have you noticed any delays in the listener for leaderboard score submission?  I have have all kinds of problems trying to display messages based on the high score.  I had moments where it would return a value, but not consistently. And now, as I try to fix it, I cannot get anything.  Manually setting a value  for myGlobalData.isleaderboardworthy shows me that the rest of my code seems to work, but I cannot get the listener to set the value…  Here is the listener function, and the scoreSubmit function - can you see anything amiss?  Maybe I am looking for the wrong event?

local function submitScoreListener( event ) print("in the submitScoreListener function") -- Google Play Games Services score submission if ( myGlobalData.gpgs ) then -- if not event.isError then --local isBest = nil if ( event.scores["all time"].isNewBest ) then myGlobalData.isleaderboardworthy = "alltime" print("in playerM.checkscore ALLTIME myGlobalData.isleaderboardworthy = "..myGlobalData.isleaderboardworthy) elseif ( event.scores["weekly"].isNewBest ) then myGlobalData.isleaderboardworthy = "weekly" print("in playerM.checkscore WEEKLY myGlobalData.isleaderboardworthy = "..myGlobalData.isleaderboardworthy) elseif ( event.scores["daily"].isNewBest ) then myGlobalData.isleaderboardworthy = "daily" print("in playerM.checkscore DAILY myGlobalData.isleaderboardworthy = "..myGlobalData.isleaderboardworthy) else myGlobalData.isleaderboardworthy = "no high score" print("in playerM.checkscore NO HIGH SCORE myGlobalData.isleaderboardworthy = "..myGlobalData.isleaderboardworthy) end -- Apple Game Center score submission elseif ( myGlobalData.gameCenter ) then if ( event.type == "setHighScore" ) then -- Congratulate player on a high score myGlobalData.isleaderboardworthy = "applehigh" native.showAlert( "Congratulations", "You set a high score!", { "OK" } ) else -- Encourage the player to do better native.showAlert( "Sorry...", "No high score, Better luck next time!", { "OK" } ) end end end local function submitScore( score ) print("in the submitScore function") -- manually setting the leaderboard value to trigger response in simulator myGlobalData.isleaderboardworthy = "daily" print("in playerM.checkscore SUBMITSCORE manually set myGlobalData.isleaderboardworthy = "..myGlobalData.isleaderboardworthy) if ( myGlobalData.gpgs ) then -- Submit a score to Google Play Games Services if mode == "reg" then myGlobalData.gpgs.leaderboards.submit( { leaderboardId = "CgkIosnt-cwwwwwww", score = score, listener = submitScoreListener }) elseif mode == "plow" then myGlobalData.gpgs.leaderboards.submit( { leaderboardId = "CgkIosnt-cwwwwwww", score = score, listener = submitScoreListener }) end elseif ( myGlobalData.gameCenter ) then -- Submit a score to Apple Game Center if mode == "reg" then myGlobalData.gameCenter.request( "setHighScore", { localPlayerScore = { category = "com.yourdomain.yourgame.leaderboard", value = score }, listener = submitScoreListener }) elseif mode == "plow" then myGlobalData.gameCenter.request( "setHighScore", { localPlayerScore = { category = "com.yourdomain.yourgame.leaderboard", value = score }, listener = submitScoreListener }) end end end

@sonyayllc. Can you post a new thread linking this tutorial by coronalabs so that coronalabs moderator can check up on you. 

the score does get submitted and stored on the leaderboard, but I can’t get the listener working… 

Thanks for taking a look!

I am not seeing any errors in the listener function. Please open a new topic so that others might help you. Sorry couldn’t be of any help. 

thanks again, using adb I was able to see that the listener is setting the variable, but my screen using it is already built/generated and not being refreshed - i have some timing issues to work through

Hello!

We are making a realtime multiplayer game that uses gpgs. We can make the room succesfully, but when we need to send the another player a reliable message using sendReliably() and he does not receive it. We used adb logcat and found this error message

 

E libjingle: Error(basicpacketsocketfactory.cc:67): UDP bind failed with error 22

 

could anyone help please?

 

The problem could occur because we do not have participantID in sendReliably() params. So how can we get the participantID

I am sorry I never worked with gpgs multiplayer. Check the official concept explanations GPGS multiplayer from Google and you can get the participant id from corona documentation.