ID:170636
 
I'm currently using Deadron's Character Handling to save in my game. After my computer recently died mid-hosting (which causes everyone to lose their data since the last time they logged out), I added a quick autosaver proc which is having some bugs.

At the end of logging in (I'm not gonna post the whole login code because I don't feel you need it all) I call the proc usr.Autosave(). Now the proc is...

mob/proc
Autosave()
sleep(6000)
client.base_SaveMob()
usr.Autosave()


It's very simple and works well for awhile. However, after an extended play time I began getting runtime errors saying that the savefile for the character could not be accessed. I didn't think to copy and paste it last night at 3 in the morning, but I will next time I see it. The problem is that it wasn't saving anymore, and after that, it doesn't save even when they exit.

Does anybody have any idea why this is happening? Thanks in advance.
Newbreedofnerd wrote:
It's very simple and works well for awhile. However, after an extended play time I began getting runtime errors saying that the savefile for the character could not be accessed. I didn't think to copy and paste it last night at 3 in the morning, but I will next time I see it. The problem is that it wasn't saving anymore, and after that, it doesn't save even when they exit.

Does anybody have any idea why this is happening? Thanks in advance.

First of all, don't uput usr in procs, with the exception of Click(), DblClick(), and Stat(). Also, you have an infinite loop, so you need to use spawn()
mob/proc
Autosave()
client.base_SaveMob()
spawn(6000)
src.Autosave()
In response to Wizkidd0123
It takes quite a while for the error message to pop up, so I won't get to test if it's working any time soon. I'm hoping it'll work though. Thanks.

Edit: Well that's just a tiny bit weird. The screen is now black when you login. O.O I can probably figure this one out on my own though.

Double Edit: Okay. That was weird. I didn't have ..() in my login, but it had never been a problem before. ^_^
In response to Newbreedofnerd
I forgot the set background=1:

mob/proc
Autosave()
set background=1
client.base_SaveMob()
spawn(6000)
src.Autosave()
In response to Wizkidd0123
Yeah. I just got the error again. T_T The error says.


Cannot open 'players\j\jas282004.sav': file is in use.
proc name: base PlayerSavefile (/client/proc/base_PlayerSavefile)
source file: implementation.dm,220
usr: Jason (/mob/player/player)
src: Jas282004 (/client)
call stack:
Jas282004 (/client): base PlayerSavefile()
Jas282004 (/client): base SaveMob()
Jas282004 (/client): base SaveMob()
Jas282004 (/client): Del()
runtime error: Cannot modify null.cd.
proc name: base SaveMob (/client/proc/base_SaveMob)
source file: implementation.dm,308
usr: Jason (/mob/player/player)
src: Jas282004 (/client)
call stack:
Jas282004 (/client): base SaveMob()
Jas282004 (/client): base SaveMob()
Jas282004 (/client): Del()


That's an example of one that I got.
In response to Newbreedofnerd
As for the runtime error, what is line 220 in implentation.dm?


And heres a suggestion for your autosave proc, you might want to make a loop in it to save all the players in the world, if thats what your aiming at. If that is what your trying to do, and multiple places, it'd be easier to do it like that in the proc, than type out the loop each time. Just wanted to let you know.




-Doh
In response to Newbreedofnerd
The problem seems to be that src was null. Also, Doh's suggestion is a good one because otherwise, you've got a seperate loop running for each mob.

proc/Autosave()
set background=1
for(var/client/C in world)
if(C.mob)//If the client actually has a mob to save
C.client.base_SaveMob()
spawn(6000)
Autosave()