GPGS Help needed!

I have changed it to local and I have copied the main.lua google play code to evey scene where I am using it but still no sucess still the same output

It’s probably not that simple. I recommend this:

In “main.lua”, reference GPGS under a local namespace:

[lua]

local gameNetwork = require( “gameNetwork” )

[/lua]

Also do your initialization tasks in “main.lua”.

In other scenes, do the same “local require()” of “gameNetwork” as shown above.

okay let me try to just intialize in every scene. I will be posting back in 2 mins. Please keep an eye I need to get this done. 

In main.lua I simple have a few forward reference setup and goto scene 

nope, still the same problem :confused:

I will probably need to see your updated code.

Also, can you please take out the Apple Game Center stuff for the moment? It’s making it more difficult to debug with that in place…

okay… here is my main.lua:

local gameNetwork = require( "gameNetwork" ) local playerName local function loadLocalPlayerCallback( event ) playerName = event.data.alias -- YOU DO NOT DEFINE THE FOLLOWING FUNCTION ANYWHERE; THAT IS A PROBLEM TO FIX --saveSettings() --save player data locally using your own "saveSettings()" function end local function gameNetworkLoginCallback( event ) gameNetwork.request( "loadLocalPlayer", { listener=loadLocalPlayerCallback } ) return true end local function gpgsInitCallback( event ) gameNetwork.request( "login", { userInitiated=true, listener=gameNetworkLoginCallback } ) end local function gameNetworkSetup() gameNetwork.init( "google", gpgsInitCallback ) end ------HANDLE SYSTEM EVENTS------ local function systemEvents( event ) print("systemEvent " .. event.type) if ( event.type == "applicationSuspend" ) then print( "suspending..........................." ) elseif ( event.type == "applicationResume" ) then print( "resuming............................." ) elseif ( event.type == "applicationExit" ) then print( "exiting.............................." ) elseif ( event.type == "applicationStart" ) then gameNetworkSetup() --login to the network here gameNetwork.request("login", { userInitiated = false }) end return true end Runtime:addEventListener( "system", systemEvents )

here is my menu.lua which has the button to show the leaderboard:

local gameNetwork = require( "gameNetwork" ) local function leadertapd(event) -- DO YOU EVEN SEE THIS SHOWN IN THE CONSOLE??? print("Leaderboard Tapped") -- FOR TESTING, COMMENT OUT ANYTHING ELSE UNRELATED    --audio.play(btn)    --audio.pause(menuMusic)    --ads.hide("banner", {appId=bannerAppID }) -- YOU SHOULD PROBABLY HANDLE CONNECTION ISSUES IN main.lua, NOT HERE. -- IF THE USER IS NOT CONNECTED, MAKE THEM CONNECT BEFORE EVER COMING TO THIS MODULE    --[[if gameNetwork.request("isConnected")  then       local function showLeaderboards( event )       gameNetwork.show( "leaderboards" )       return true end    else       gameNetwork.request("login", { listener = loginListener, userInitiated = true })       local function showLeaderboards( event )     if ( system.getInfo("platformName") == "Android" ) then       gameNetwork.show( "leaderboards" )     else       gameNetwork.show( "leaderboards", { leaderboard = {timeScope="AllTime"} } )     end     return true end        end--]] gameNetwork.show( "leaderboards" ) end          local leaderboard= widget.newButton {defaultFile = "BG.png", onRelease= leadertapd} leaderboard.x=centerX-4 leaderboard.y= centerY-10 -- YOU SHOULD NOT SET WIDGET BUTTON WIDTH/HEIGHT AFTER CREATION (BAD PRACTICE) leaderboard.width = 147 leaderboard.height=50 leaderboard.alpha=0.01 sceneGroup:insert(leaderboard)

here is my gameOver.Lua which updates the score at the end of the game:

local gameNetwork = require( "gameNetwork" ) --===============UPDATING LEADERBOARD==================================== local function postScoreSubmit( event ) --whatever code you need following a score submission... return true end local myScore = 100 --for GPGS, reset "myCategory" to the string provided from the leaderboard setup in Google -- BIG PROBLEM: YOU ARE NOT SPECIFYING AN ACTUAL LEADERBOARD ID -- HOW DOES GPGS KNOW WHAT LEADERBOARD TO UPDATE??? local myCategory ="my leaderboard id here" gameNetwork.request( "setHighScore", { localPlayerScore = { category=myCategory, value=tonumber(score) }, listener = postScoreSubmit } ) --==============================ENDING LEADERBOARD==================================

I’ve modified your code and added some comments. Take a look and ask further questions…

I have modified the code acordingly but still no luck. and yes I do see the print statement Leaderboard Tapped shown on the console.

and I do have my leaderboad id here 

local myCategory ="my leaderboard id here"

in my actual code. I just replaced it here

But you say that it does allow you to log in to GPGS?

If so, let’s try doing this all within “main.lua” for testing. Add a few lines to your “loadLocalPlayerCallback()” function as follows…

[lua]

local function loadLocalPlayerCallback( event )

   playerName = event.data.alias

   – YOU DO NOT DEFINE THE FOLLOWING FUNCTION ANYWHERE; THAT IS A PROBLEM TO FIX

   --saveSettings()  --save player data locally using your own “saveSettings()” function

   – DO YOU SEE THIS IN THE CONSOLE?

   print( “IT IS REACHING HERE…” )

   gameNetwork.show( “leaderboards” )

end

[/lua]

yes, I said “It ask me to login and sometime even shows the screen where it asks for users the permission to access the profile and stuff”

it did ask me a few times before but its not asking me now… even when it logged in I coudnt open the leaderboard.

I have tried your code I cannot see iT IS REACHING HERE in the debug mood. ( just to add on I doo see the google play services logo pop up and trying to login in but then it just goes away…this was hapening even before)

I have created a new key and signed using that my new apk and also updated the sha1 in the google developer account now I do get to login screen the 1st time and sign in, giving it the permission to access my profile but only once. I think it saves the prefernces so next time I do not have to login and it auto logs in. But I still cant get to show the leaderboard!

On this new test, did it ever reach that print() statement “IT IS REACHING HERE…”, even if only on the first login?

Please put some print() statements in all of the other listener functions as well: “gameNetworkSetup()”, “gpgsInitCallback()”, and “gameNetworkLoginCallback()”. Then, try to clear out the “preferences” or log out of GPGS entirely so you can start with a clean plate. Then test and see which of those functions is actually getting called.

By the way, why are you doing a “return true” from the “gameNetworkLoginCallback()” function? It shouldn’t matter that it’s there, but then, I see no reason for it being there either.

Is there a reason you’re calling login multiple times?

@Rob

not really, I was just trying to make it work that way as it wasn’t running with even single login attempt. Was just testing it out.

Thank you Corona Staff , I actually figured out the problem it wasn’t with corona it was with Google. When It asked me to enter sha1 key I did and it did proceeded and gave me Oauth certificate. but then as I was strugling to log on I went in to the developer section under credentials tab I clicked on the project and found that my sha1 key wasn’t saved their it was blank. So I again had to put in my sha1 key and now its up and working as it should.

Please check it and update the guide to setup gpgs as it will really be helpful for the new and old users