ID:179710
 
How can I make it so once a usr logs out, his scores (var/score) is saved, and once logged back in, it goes back (without using the character saving library)?
mob/Logout()
var/savefile/F = new("[src.ckey].score")
F["scores"]<<src.score

mob/Login()
var/savefile/F = new("[src.ckey].score")
F["scores"]>>src.score


I don't think using .score will be any different from using .sav since it's defined as a savefile, this way the player can have .sav for character files and .score for score file. This loads the score var (change that to what you use for your score) and only that var into the file apon logout, and loads the scores up apon login.
In response to Nadrew
Nadrew wrote:
mob/Logout()
var/savefile/F("scores.sav")
F["scores"]<<src.score

mob/Login()
var/savefile/F("scores.sav")
F["scores"]>>src.scores

Nadrew, if you're not going to pay enough attention to your own code or the question to write a half-decent answer, please don't bother. Answer people with words or with code you have a reasonable assurance will work (i.e., look at it a second or third time before you post). These half-baked snippets are annoying. No offense intended, but... gads. I think I've seen you answer about one question out of eight correctly this way, and the other times are all messed up.

There are several problems with your approach:

1) You didn't settle on a variable name, but used "score" in one and "scores" in another. Instant compiler error.
2) Unless only one player is playing, using the key "scores" in the save file is kinda stupid. The key should be src.client.ckey or something derived from it.
3) If this is the player's first time (or if no one has played before, which is how your code would behave), there won't be an entry under their key in the save file. You should check for this case.

Alternatively, if the player has other attributes being saved, their score could simply be saved along with them in the appropriate save file.

Lummox JR
In response to Lummox JR
I've been under alot of stress lately, I edited the code some. The last couple of weeks have been hard for me,I didn't notice my mistakes thanks for pointing them out to me.
In response to Nadrew
Nadrew wrote:
I've been under alot of stress lately, I edited the code some. The last couple of weeks have been hard for me,I didn't notice my mistakes thanks for pointing them out to me.

Being under stress is certainly understandable; I've been under heaving gobs of it myself for the last two months.

Your code, however, is still screwed up. It looks like it'll work, but it's totally inane; you're using different save files with one key each when you could just use one save file with different keys for each player's score.

I actually don't attribute your code to stress; this is more of a pattern in the way you usually answer questions, and I've seen you do it for the whole time I've been in the community. You brush through the question, usually understanding it but not always, then post a snippet of code that almost certainly won't work or is poorly thought-out. In general I think it would be best to just explain the key function calls that will do the trick and point people to the reference for more info than to write code for them, because when you post code you don't seem to pay enough attention to posting something correct.

Lummox JR
In response to Nadrew
Thanks allot. this is what I really needed for a type of game I will be making in awhile.