Cannot post score to a Leaderboard
Closed this issue · 14 comments
I'm able to sign in to the play game services and access the leaderboard. I'm unable to post any score to the leaderboard using the code
LeaderboardsClient.submit_score(leaderboard.leaderboard_id, somescoreAsInt)
I even tried passing the actual value of my leaderboard as a string and a integer value for the score but it still doesn't update the score.
Hi! Do you see any errors in logcat?
If you check the Leaderboards.tscn
scene in the demo project, you will see that I first make a call to LeaderboardsClient.load_all_leaderboards(true)
to get all the leaderboards and then use the leaderboard id from that to add new scores. The code to add new scores is in the LeaderboardDisplay.gd
script.
You can try running the demo app with your game id and check if it works in the demo app. Then you can use the code there as inspiration.
Tried using the LeaderboardsClient.load_all_leaderboards(true) but I still could not use the leaderboard.leaderboard_id. Kept getting the error:
10-09 01:54:53.801 7424 7664 E godot : USER SCRIPT ERROR: Invalid access to property or key 'leaderboard_id' on a base object of type 'Nil'.
I tried the demo project. Even it is able to show the leaderboard. But when I try to submit a new score, it doesn't work.
Logcat:-
10-09 02:10:32.211 14111 14209 E godot : Unexpected data received from JSON Dictionary:
10-09 02:10:32.211 14111 14209 E godot : null
That's weird indeed. You have all changes of your leaderboards in your Play Console published? it's weird that the load all leaderboards method returns nothing if the game is showing leaderboards.
The leaderboard is published on the Play console and it was working with another plugin on Godot 3.x. I'll try to recreate the Leaderboard in the weekend and try again.
Hi @Iakobs,
I've deleted the old leaderboard and created a new one and I still can't post the scores to the leaderboard even though I can open the leaderboard within the app (it doesn't have any score yet).
In json_marshaller.gd, I've tried playing around with the code and added few print code to output the error:
func safe_parse_dictionary(json_dictionary: String) -> Dictionary:
var error := _json.parse(json_dictionary)
print("JSON Error Code: ", error)
print("JSON Data: ", _json.data)
When running the app, it first displayed this error:
10-12 13:07:21.955 18215 18267 I godot : JSON Error Code: 0
10-12 13:07:21.955 18215 18267 I godot : JSON Data: <null>
Then I tried adding the code in Leaderboards.gd and ran the app
func _ready() -> void:
if _leaderboards_cache.is_empty():
LeaderboardsClient.load_all_leaderboards(true)
LeaderboardsClient.load_leaderboard("actual leaderboard id", true)
I then got the below output:
10-12 13:11:47.815 22342 22427 I godot : JSON Error Code: 0
10-12 13:11:47.815 22342 22427 I godot : JSON Data: { "iconImageUri": "user://iconImageUri_*************.png", "displayName": "Rankings", "scoreOrder": "SCORE_ORDER_LARGER_IS_BETTER", "leaderboardId": ".......
10-12 13:11:49.249 22342 22427 I godot : JSON Error Code: 0
10-12 13:11:49.250 22342 22427 I godot : JSON Data: <null>
There may be something wrong with the load_all_leaderboards
function but I'm not sure yet but I still cannot post scores to the leaderboad
Hi! Just wanted to let you know that this weekend I'm out so I can't check the issue properly. I will get back to you during the next week, let's see if we can fix it!
Hi @RashwinBarwa sorry for the delay!
It's difficult to understand the problem, but for what I see, the LeaderboardsClient.load_all_leaderboards(true)
is working fine, since the prints you added to the json_marshaller.gd
script are outputting the data, but then the LeaderboardsClient.load_leaderboard("actual leaderboard id", true)
is not returning anything, which is weird. Is that correct?
I can't figure out the issue with the information I have right now. The only thing I can think of is that you're not passing the correct leaderboard id to the load_leaderboard
or submit_score
functions.
Hi @Iakobs
I've now been trying this on the Demo app with regular Godot build (I'm not using custom builds to reduce size for this testing) and I'm still not able to post scores to leaderboard. I'm not sure where I'm going wrong.
I'm so sorry to hear that, and I can't see anything wrong from the examples you posted here. I'm still inclined to think there's something not properly configured in the Google end, but can't think of what exactly. The leaderboards being properly displayed but you not being able to post scores to it sounds like a configuration problem. Do you have any logs from Google packages in logcat?
im coincidentally working on something similar right now, and am seeing the same issue in EthannYakabuski/AnimalDash#37
i spent a good few hours figuring out the login convinced something was wrong, but it did end up being some silly configuration mistake, so i trust when @Iakobs says its likely a config issue with this leaderboardsClient as well.
when/if i figure out what might be going on, ill get back to you @RashwinBarwa , hopefully were having the same silly config issue and i can figure it out for us
I hope its a configuration problem. I'm starting again from scratch on OAuth2 Android Client in Google Cloud. Just waiting for the verification to complete.
@EthannYakabuski can you share the mistake you did, I may be doing it too without realizing.
@RashwinBarwa - Hey update - I was able to successfully integrate the leaderboard (can see updated PR here: EthannYakabuski/AnimalDash#37). The problem is that my issue was because i was just sending 0 to the leaderboard as the score because i was mistakingly referencing the wrong variable (HAHA)
that being said i did brainstorm a few other things for you to double check:
These are all just really shots in the dark - what i tried before realizing my silly mistake (make sure the score you are passing is bigger than 0 lol)
A) In google play console -> The list of testers underneath "Google Play Services" seems to be different than the list of internal testers found at the "internal testing" section of the website.
B) In google play console -> triple check your leaderboard is published (i know you already said you did, and tried with a fresh leaderboard so in this case double check the "Publishing" underneath the Google Play game services section, and make sure your updates aren't pending update there by accident
C) If all else fails -> in google play console turn off tamper protection. this is a crazy though but maybe something about your stack or the way you are emulating a device (are you emulating a device? im just testing on my phone) -> might be causing GPS to think the score you are submitting is frauduelnt. try turning off this setting perhaps
D maybe you need to add this xml file to your android\build\res\values folder
If its still not looking take a close look again at the demo code in the plugin:
https://github.com/godot-sdk-integrations/godot-play-game-services/blob/main/plugin/demo/scenes/leaderboards/LeaderboardDisplay.gd
and take another look at my pr into my own godot app: (are you doing something more confusing then these basic lines of code?) (are you setting the signal connection in the ready() method?) https://github.com/EthannYakabuski/AnimalDash/pull/37/files
if still not working, please share some code snippets
Hi @RashwinBarwa I will close this issue since it looks like the problem was solved. Feel free to reopen this one or create another if you need anything else :)