Hi guys, I’m creating a Facebook leaderboard but I have some problems when I update it. When I update the facebook score and then open the leaderboard, it shows me the old score. If I close the game and I oped the game again, it shows the correct leaderboards. What am I doing wrong? Here the code:
function fClassificaFb(event) if event.phase == "began" then bpClassificaFb.isVisible = true end if event.phase == "moved" then bpClassificaFb.isVisible = false end if event.phase == "ended" then bpClassificaFb.isVisible = false fbAggiornaClassifica() timer.performWithDelay(150, fbVisualizzaClassifica, 1) end end function fbVisualizzaClassifica(event) local status = network.getConnectionStatus() if status.isConnected then facebook.login(appID, fbListener) else fbAlert = native.showAlert("Errore di connessione", "Non è stata rilevata alcuna connessione a Internet.", {"Annulla", "Riprova"}, fbReLogin) end end function fbAggiornaClassifica() local status = network.getConnectionStatus() if status.isConnected then facebook.login(appID, fbListenerAggiorna) else fbAlertAggiorna = native.showAlert("Errore di connessione", "Non è stata rilevata alcuna connessione a Internet.", {"Annulla", "Riprova"}, fbReLoginAggiorna) end end function fbListener(event) if "session" == event.type then if "login" == event.phase then access\_token = event.token facebook.request(appID.."/scores") end elseif "request" == event.type then local response = json.decode(event.response) myData.dataFriends = response.data storyboard.gotoScene("classifica\_facebook") end end function fbListenerAggiorna(event) if "session" == event.type then if "login" == event.phase then access\_token = event.token if storyboard.state.punteggio \> myTable.highScore then myTable.highScore = storyboard.state.punteggio end loadsave.saveTable(myTable, "myTable.json") local attachment = { score = tostring(myTable.highScore) } facebook.request("me/scores" , "POST", attachment) elseif "request" == event.type then end end end