So I made some code to detect if a certain achievement has been completed, but it still keeps on unlocking the achievement, need some help please?
[lua]local achievementId_to_check = “”
– check the achievements
local function requestCallback( event )
if event.type == “loadAchievements” then
if event.data then
for i,v in pairs(event.data) do
if (event.data[i].identifier == achievementID) then
achievementId_to_check = “”
return true – achievement done!
end
end
achievementId_to_check = “”
return false – achievement done!
end
end
end
function check_achievement( achievementID )
– check if iOS device and connection is active
achievementId_to_check = achievementID
return gameNetwork.request( “loadAchievements”, { listener=requestCallback } )
end
function unlockAchievement( achievementID )
– check if iOS device and connection is active
if (model == “iPad” or model == “iPhone” or model == “iPod touch”) and testNetworkConnection() and loggedIntoGC then
– check if achievement is complete
if (check_achievement(achievementID)) then
else
gameNetwork.request( “unlockAchievement”,
{
achievement =
{
identifier = achievementID,
percentComplete = 100,
showsCompletionBanner = true,
},
listener = requestCallback
})
end
end
end[/lua]
usage:
[lua]unlockAchievement(“complete6x6board002”)[/lua] [import]uid: 186198 topic_id: 33015 reply_id: 131062[/import]