Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Make an offline highscore table?

Author
Message
easter bunny
12
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 21st Nov 2012 01:15
Hey everybody,
I am programming a game, and I need an offline high score table,
But I can't figure out how to do it.
The way I have done it (that doesn't work) is have a file set out like this:
entry1: 115
Joe Rnd: 102
John Smith: 97
ETC
Then I load each line into an array and extract then score and position, the program then goes though the array from highest to lowest, as soon as your score is HIGHER then one of them, it will exit the for/next loop and remember the position.
The way I would like to do it is delete the original file, replace the offending score, and remake the file with the original scores, but I can't delete the file, AppGameKit won't let me.
The other way I would do it is replace the line in the file, but I can't figure out how.
Can anybody help me?

JoJo
xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 21st Nov 2012 05:02
As long as the file you are reading from is in a directory that the user has write access to, you should have no problems recreating it with the modified array of scores using OpenToWrite(ID, "filename.ext")

This command, by default, will overwrite the existing file if it exists so there's no need to manually delete it using DeleteFile.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 21st Nov 2012 11:56
Don't forget to closeFile() after reading the scores in, otherwise it will be locked out.

easter bunny
12
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 24th Nov 2012 03:12
Thanks, I didn't realise that OpenToWrite() will overwrite the file
This helps a lot
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 25th Nov 2012 18:44
The first time you use OpenToWrite(), it will create the file of the same name in the app sandbox area. It will not overwrite the original file that was delivered with the game.

Cheers,
Ancient Lady
AGK Community Tester

Login to post a reply

Server time is: 2024-11-24 04:38:28
Your offset time is: 2024-11-24 04:38:28