ID:1263272
 
(See the best response by Murrawhip.)
Logout Proc:
    Logout()
src.Save()
world << output("[name]([src.ckey]) has logged out.", "output1")
del src

Load Proc:
    Load()
set hidden=1
clicking=1
if(fexists("Saves/[src.ckey].sav"))
var/savefile/F=new("Saves/[src.ckey].sav")
Read(F)
src.loc=locate(F["xxx"],F["yyy"],F["zzz"])
winset(src, null, "mainwindow.is-visible=true;login.alpha=0")
Load_Stats()
winset(src,"stats.health","text=\"[Health]/[Max_Health]")
winset(src,"stats.stamina","text=\"[Stamina]/[Max_Stamina]")
winset(src,"stats.strength","text=\"[Strength]")
winset(src,"stats.speed","text=\"[Speed]")
winset(src,"stats.swordskill","text=\"[Sword_Skill]")
winset(src,"stats.level","text=\"[level]")
winset(src,"stats.sorcery","text=\"[Sorcery]")
winset(src,"stats.stat_points","text=\"[stat_points]")
winset(src,"stats.exp","text=\"[exp]/[mexp]")
winset(src,"inventory.Doubloons","text='[src.Doubloons]'")
world << output("[name] has logged in.", "output1")
src.BasicSkillProc()
src.FireSkillsProc()
usr.UpdateInv()
clicking=0
if(usr.key in list ("Micdogmic",""))
src.CreateMapText("<font color=\"#3BB9FF\">[src]</font><br>[src.Rank]")
return
if(usr.key in list ("AreYouScared"))
src.CreateMapText("<font color=\"#8D38C9\">[src]</font><br>[src.Rank]")
return
else
src.CreateMapText("[src]<br>[src.Rank]")
else
return

Save Proc:
    proc
Save()
set hidden=1
var/savefile/F=new("Saves/[src.ckey].sav")
F["xxx"]=x
F["yyy"]=y
F["zzz"]=z
Write(F)

Reboot Proc:
mob/verb/Reboot()
if(usr.key in list ("Micdogmic","AreYouScared","Kidsparda"))
world.Reboot()


Problem description:Sometimes when a player will load a character on the server, it will reboot the server, and erase/rollback other players characters. Also, when I reboot the server, all savefiles will be deleted.
If you need any other codes, just ask.


Well I'm not sure of the exact cause, but here's some tips to improve your code here:
  • unless its needed, consistently use src or usr - don't alternate
  • don't directly call Read() or Write(). Just send the mob directly to the save file.
  • why are you calling del src in Logout()? Just call the default procedure - ..()
  • why are you checking if the key is in a list of one element rather than comparing directly?
  • you shouldn't need to use set hidden in a proc - they are already hidden from mobs

I could go on, but I'll leave it there for now.

If I had to pick one of these as the most likely cause for save files not saving correctly, it would either be calling del src in Logout() rather than the default procedure or directly calling Read and Write.
In response to Albro1
Albro1 wrote:
If I had to pick one of these as the most likely cause for save files not saving correctly, it would either be calling del src in Logout() rather than the default procedure or directly calling Read and Write.

Logout() doesn't delete the mob by default.
In response to Murrawhip
Murrawhip wrote:
Albro1 wrote:
If I had to pick one of these as the most likely cause for save files not saving correctly, it would either be calling del src in Logout() rather than the default procedure or directly calling Read and Write.

Logout() doesn't delete the mob by default.

I know, I never said it did. The mob stays and it's key variable stays as well - which means the client, when it logs back in, will be assigned that mob.

What I don't have a clear understanding of is the internals of Logout(), but that very lack of knowledge advises me to call the default procedure whenever I must override it so I'm not skipping over anything it would do for me.
In response to Albro1
Best response
Albro1 wrote:
why are you calling del src in Logout()? Just call the default procedure - ..()

Calling the default Logout procedure (which does nothing by default) wouldn't be a suitable replacement for deleting the mob. I'm sure if he wanted the mob to stick around, he wouldn't try to delete it.

You suggested that his problem might be due to "calling del src in Logout", which I'm saying it's not. You don't have to defend yourself against a correction.
In response to Murrawhip
I do wonder why you have a vote for your response to me being the best response to the current issue. We haven't even identified what exactly the problem is yet. People are strange.
Can you show what these procs/verbs are under? The load looks like a verb and the save is a proc? Under mob?