This site requires JavaScript, please enable it in your browser!
Greenfoot back
Kartoffelbrot
Kartoffelbrot wrote ...

2013/5/15

UserInfo

Kartoffelbrot Kartoffelbrot

2013/5/15

#
I am using UserInfo for Tiny Tank, to save the players stats. But it doesn't save all data. What's my mistake?
public void saveUserData()
    {
        if (UserInfo.isStorageAvailable())
        {
            UserInfo m = UserInfo.getMyInfo();
            m.setInt(0, Superklasse.mines);
            m.setInt(1, Superklasse.geld);
            m.setInt(2, Superklasse.motorF);
            m.setInt(3, Superklasse.panzerungF);
            m.setInt(4, Superklasse.nachladenF);
            m.setInt(5, Superklasse.munitionskapazitaetF);
            m.setInt(6, Superklasse.abschuesse);
            m.setInt(7, Superklasse.tode);
            m.setInt(8, Superklasse.selbstmorde);
            m.setInt(9, Superklasse.levelFreigeschaltet);

            if(Superklasse.tigerF==true)
                m.setString(0, "enabled");
            if(Superklasse.tigerF==false)
                m.setString(0, "disabled");
            m.store();
        }
    }
Do I have to write m.store() everytime?
davmac davmac

2013/5/15

#
You have to call the store() method every time you want to store the data to the server. You don't have to call it after every time you change a single data item, if that's what you're asking.
But it doesn't save all data.
Could you be more specific? What data doesn't it save, and how do you know?
Kartoffelbrot Kartoffelbrot

2013/5/15

#
For example it doesn't save the variable levelFreigeschaltet ind line 15. But geld in line 7 is saved. I don't actually know all variables, which are/aren't saved. I realized that as friends told me. And it doesn't save everything on my account, too.
danpost danpost

2013/5/15

#
I usually double-check programmatically that all items are saved properly before continuing, somehow informing the user that everything was saved ok or not; and offering to attempt saving again, if there was a problem. This requires that you re-acquire the UserInfo data using 'getMyInfo' (again after storing) and check its values with what they now should be.
davmac davmac

2013/5/15

#
Kartoffelbrot, I don't want to sound dismissive, but I think there's a good chance the problem is in your own code. Can you produce a small but complete example scenario which shows the data items failing to save / load? If so we'll look and see if there's a Greenfoot bug.
Kartoffelbrot Kartoffelbrot

2013/5/17

#
No problem, but now I found my mistake: It was a bug, with the saving button -.- Thanks to all helpers.
You need to login to post a reply.