I usage silent_login by default and “Login” button on main screen for those players, who disabled silent mode.
1 Like
britzl
September 12, 2020, 11:49am
22
The Google Play Game Services extension has been updated with a crash fix for gpgs.leaderboard_get_player_score()
. The new version also contains a fix for general error handling where error messages weren’t correctly formatted.
There’s also ongoing work to fix a scenario where gpgs.leaderboard_submit_score()
doesn’t log the correct score in the leaderboard: https://github.com/defold/extension-gpgs/issues/25
4 Likes
jorpak
February 23, 2023, 3:50pm
23
How to unlock achievement? I’ve read the documentation but I’m bit confused about unlock, show and get functions?
And can I retrieve players highscore from leaderboard?
britzl
February 23, 2023, 8:56pm
24
You unlock achievements by calling gpgs. achievement_unlock(achievement_id)
:
https://defold.com/extension-gpgs/api/#achievement_unlock:achievementId
jorpak:
show
I think you want the gpgps.achievement_show()
function:
https://defold.com/extension-gpgs/api/#achievement_show
In fact, you can check the example project if you are unsure of how to use GPGS:
local dirtylarry = require "dirtylarry.dirtylarry"
local monarch = require "monarch.monarch"
local function gpgs_callback(self, message_id, message)
print(message_id)
pprint(message)
end
function init(self)
msg.post(".", "acquire_input_focus")
if gpgs then
gpgs.set_callback(gpgs_callback)
end
end
function on_input(self, action_id, action)
dirtylarry:button("reveal", action_id, action, function ()
if gpgs then
gpgs.achievement_reveal("CgkIq5-gxcsVEAIQAQ")
This file has been truncated. show original
self.clicks = self.clicks + 1
print(self.clicks)
gui.set_text(gui.get_node("clicks"), tostring(self.clicks))
end
dirtylarry:button("submit_score", action_id, action, function ()
gpgs.leaderboard_submit_score("CgkIq5-gxcsVEAIQAg", self.clicks)
end)
dirtylarry:button("top_scores", action_id, action, function ()
gpgs.leaderboard_get_top_scores("CgkIq5-gxcsVEAIQAg", gpgs.TIME_SPAN_ALL_TIME, gpgs.COLLECTION_PUBLIC, 10)
end)
dirtylarry:button("player_centered_scores", action_id, action, function ()
gpgs.leaderboard_get_player_centered_scores("CgkIq5-gxcsVEAIQAg", gpgs.TIME_SPAN_ALL_TIME, gpgs.COLLECTION_PUBLIC, 10)
end)
dirtylarry:button("player_score", action_id, action, function ()
gpgs.leaderboard_get_player_score("CgkIq5-gxcsVEAIQAg", gpgs.TIME_SPAN_ALL_TIME, gpgs.COLLECTION_PUBLIC)
end)
And:
or message_id == gpgs.MSG_GET_TOP_SCORES then
local s = ""
for _,score in ipairs(message) do
score = json.decode(score)
s = s .. ("%s - %s (%s)\n"):format(score.score_holder_name, score.display_score, score.display_rank)
end
gui.set_text(gui.get_node("scores"), s)
end
2 Likes
jorpak
February 23, 2023, 9:08pm
25
What does achievement_get do? API doc doesnt have any description on that one.
britzl
February 23, 2023, 10:25pm
26
Almost all Google Play Game Services APIs are asynchronous which means that you do not get the data immediately in the function call but some time later in a callback. In the example the achievement data is received in the callback here:
function gpgs_callback(self, message_id, message)
print(message_id)
pprint(message)
end
function init(self)
msg.post(".", "acquire_input_focus")
if gpgs then
gpgs.set_callback(gpgs_callback)
end
end
1 Like