How do I: Save scores?

Get help using Construct 2

Post » Tue Nov 08, 2016 1:23 am

Hey,

So I made an app where if the user is at school, on-time(8:45am), it will award them 1000 points by checking their geolocation and using system time. Only problem is that I can't get the score to save using local storage. The score just comes up as NaN or just stays at 0 everytime I tried using local storage. I want the app the save the user's collective score.


This is my first time ever using Construct 2, so help would be very much appreciated!

Thanks!

Image
B
4
S
1
Posts: 4
Reputation: 308

Post » Wed Nov 09, 2016 5:42 pm

The local storage is only active so long as the app is running. If you close the app the local storage is cleared.

You have to have a server database to save data between sessions, or just keep your app open constantly.

One side question, what if they simply change the system time?
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
23
S
6
G
1
Posts: 1,419
Reputation: 4,857

Post » Wed Nov 09, 2016 6:06 pm

gumshoe2029 wrote:The local storage is only active so long as the app is running. If you close the app the local storage is cleared.


No. This is wrong. The local storage data persists even if the app is closed.
The Things you can create is only limited by your imagination. If you don't have the skills then use your motivation as a natural force to exceed all expectations. Chadori RebornXD
B
65
S
21
G
90
Posts: 1,124
Reputation: 59,862

Post » Wed Nov 09, 2016 6:08 pm

chadorireborn wrote:No. This is wrong. The local storage data persists even if the app is closed.


I stand corrected then.
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
23
S
6
G
1
Posts: 1,419
Reputation: 4,857

Post » Wed Nov 09, 2016 6:10 pm

@SecretaryBird - Local storage should work.... Can you show the rest of the event, especially the part when you set the score value to the local storage? But providing a .capx is better.
The Things you can create is only limited by your imagination. If you don't have the skills then use your motivation as a natural force to exceed all expectations. Chadori RebornXD
B
65
S
21
G
90
Posts: 1,124
Reputation: 59,862

Post » Wed Nov 09, 2016 6:12 pm

Nan usually means you are trying to use the wrong data type.
As I recall, storage only uses strings, so you should probably add an int() to the return values.

Also, think of local storage as you would a cookie.
Image ImageImage
B
170
S
50
G
179
Posts: 8,378
Reputation: 113,425


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests