godot-sdk-integrations / godot-play-game-services

A Godot 4.x plugin for integration with Google Play Game Services
MIT License
138 stars 10 forks source link

Cannot post score to a Leaderboard #36

Open RashwinBarwa opened 2 weeks ago

RashwinBarwa commented 2 weeks ago

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.

Iakobs commented 2 weeks ago

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.

RashwinBarwa commented 1 week ago

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

Iakobs commented 1 week ago

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.

RashwinBarwa commented 1 week ago

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.

RashwinBarwa commented 1 week ago

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

Iakobs commented 1 week ago

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!

Iakobs commented 4 days ago

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.

RashwinBarwa commented 2 days ago

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.

Iakobs commented 2 days ago

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?