ID:157814
 
Sometimes players on my games files corrupt.. I talked to a friend and he said it happened to him when he clicked load twice and it messed up because of lag, but I'm not sure if that's true.

What happens is they click load, and then it says they logged in but it brings them no where, and they can keep clicking load..

This has happened to me a number of times.. Any idea what might cause it? Thanks.

I think it may have something to do with failed connections.. any way to fix this?
It's likely an issue with how you are saving/loading, not something to do with the BYOND software.
In response to Garthor
mob
proc
LoadFile()
if(fexists("players/[src.key].sav"))
var/savefile/F = new("players/[src.key].sav")
Read(F)
for(var/stuff in src.V)
src.verbs += stuff
world<<"<font size=1><font color=red><B>Info: <font color=red>[src.key] has logged in..."
view(src) << sound(null)
if(src.zco==1)
if(src.xco > 201)
src.xco= 62
if(src.yco > 208)
src.yco=121
if(src.xco < 54)
src.xco= 62
if(src.yco < 67)
src.yco=121
src.loc = locate(src.xco,src.yco,src.zco)
src.OOC=1
src.Say=1
if(istype(usr,/mob/))
if(usr.client)
usr.icon = usr.Picon
usr.icon = usr.Picon
if(usr.key == "Xyphon101")
usr.verbs += typesof(/mob/Owner/verb)
usr.verbs += typesof(/mob/Player/verb)
usr.verbs += typesof(/mob/Moderator/verb)
usr.verbs += typesof(/mob/GalacticLeader/verb)
usr.verbs += typesof(/mob/Org/verb)
usr.rank="Owner"
usr.Money = 9999999
usr.GM=1
usr.Org="Galactic"
usr.Orgs=1
usr.Class="Leader"
if(usr.key=="Joequel")
usr.verbs += typesof(/mob/Owner/verb)
usr.verbs += typesof(/mob/Player/verb)
usr.verbs += typesof(/mob/Moderator/verb)
usr.verbs += typesof(/mob/RocketLeader/verb)
usr.verbs += typesof(/mob/Org/verb)
usr.rank="Co-Owner"
usr.Money = 9999999
usr.GM=1
usr.Org="Rocket"
usr.Orgs=1
usr.Class="Leader"
if(usr.rank=="Player")
usr.verbs += typesof(/mob/Player/verb)
else
src<<"You do not have a file on this server"


That's my load, and my save is autosave... This is my auto save..

mob
Logout()
world<<"<font color=red>[src] has logged out</font>"
if(src.pokemonout)
src.ReturnProc(src.SentOutPokemon1)
src.SaveFile()
var/SentOutPokemon = src.SentOutPokemon1
src.overlays-='pokeball2.dmi'
del SentOutPokemon
del(src)


mob
proc
SaveFile()
var/savefile/F = new("players/[src.key].sav")
src.V = src.verbs
src.xco = src.x
src.yco = src.y
src.zco = src.z
Write(F)
src << "<font color=red><b>Your game has been saved!"


Can you find out what's wrong?
In response to Xyphon101
You are calling Read() and Write() directly. This results in errors under certain not-uncommon circumstances. The proper way to save and load complex objects is by using the << and >> savefile operators. For an example, I'm sure just searching the forum for "author:Garthor save" will bring up a ton of them.
In response to Garthor
I searched through and now I have

mob
proc
LoadFile()
if(fexists("players/[src.key].sav"))
var/savefile/F = new("players/[src.key].sav")
var/mob/M
F >> M
del(src)
//because reading from the savefile creates a new mob:
for(var/stuff in src.V)
src.verbs += stuff
world<<"<font size=1><font color=red><B>Info: <font color=red>[src.key] has logged in..."
view(src) << sound(null)
if(src.zco==1)
if(src.xco > 201)
src.xco= 62
if(src.yco > 208)
src.yco=121
if(src.xco < 54)
src.xco= 62
if(src.yco < 67)
src.yco=121
src.loc = locate(src.xco,src.yco,src.zco)
src.OOC=1
src.Say=1
if(istype(usr,/mob/))
if(usr.client)
usr.icon = usr.Picon
usr.icon = usr.Picon
if(usr.key == "Xyphon101")
usr.verbs += typesof(/mob/Owner/verb)
usr.verbs += typesof(/mob/Player/verb)
usr.verbs += typesof(/mob/Moderator/verb)
usr.verbs += typesof(/mob/GalacticLeader/verb)
usr.verbs += typesof(/mob/Org/verb)
usr.rank="Owner"
usr.Money = 9999999
usr.GM=1
usr.Org="Galactic"
usr.Orgs=1
usr.Class="Leader"
if(usr.key=="Joequel")
usr.verbs += typesof(/mob/Owner/verb)
usr.verbs += typesof(/mob/Player/verb)
usr.verbs += typesof(/mob/Moderator/verb)
usr.verbs += typesof(/mob/RocketLeader/verb)
usr.verbs += typesof(/mob/Org/verb)
usr.rank="Co-Owner"
usr.Money = 9999999
usr.GM=1
usr.Org="Rocket"
usr.Orgs=1
usr.Class="Leader"
if(usr.rank=="Player")
usr.verbs += typesof(/mob/Player/verb)
else
src<<"You do not have a file on this server"

mob
proc
SaveFile()
var/savefile/F = new("players/[src.key].sav")
src.V = src.verbs
src.xco = src.x
src.yco = src.y
src.zco = src.z
F << src
src << "<font color=red><b>Your game has been saved!"


Problem is when I click load it says "Xyphon101 has logged out" if I click it again it says "Connection died. Connection failed."
In response to Xyphon101
It takes more than just a find-and-replace. First, you need to realize that Login() and Logout() ARE going to be called as a result, so anything you only want to have happen when a player connects or disconnects goes in client/New() and client/Del().

Next, you need to move the majority of those procs to mob/Write() and mob/Read().

Also, the proc will stop when you delete src, but everything after that should be in mob/Read() anyway (though other errors in it like usr abuse should be fixed).
In response to Garthor
o_o.... yeah, I'm sorry.. But I'm not sure what exactly you are going on about. Don't link me to a dm guide or anything.. I don't even have a client/new or client/del defined anywhere.. And I don't get it.. Do you want me to put load and stuff in client/new and everything? If it calls logout when I am supposedly supposed to be fixing a problem, and in the end adding a mountain of problems there must be another way to do this.

EDIT and with mob/Read and mob/Write.. Uhh.. What procs go in where?
In response to Xyphon101
The solution causes a problem because a whole lot of your game was built upon an incorrect way of doing things. If you don't like that it takes a lot of work to fix the problem, then be more careful to do things the right way the first time.

As for your complaint that you "don't even have a client/new or client/del defined anywhere", I'm struggling to understand why this is an issue (aside from your capitalization). If they're not defined, define them.
In response to Garthor
My capitalization? Quoi? I didn't caps anything. Anyway, I still need to know, what do I put in read and write? I thought read was reading a save file.. But putting an entire load script in it? I don't get it.
In response to Xyphon101
Any processing that needs to occur in order to properly read from a savefile goes in Read(). And processing that needs to occur in order to properly write to a savefile goes in Write().
In response to Garthor
I have
Del()
mob.Logout()
New()
mob.Login()

under my client

And for some reason, as soon as I go on, it destroys my connection..
In response to Xyphon101
First, you shouldn't be calling Login() like that. Second, your connection will be dropped if you don't have a mob, which is what happens when you override client/New() to prevent it from giving you one, as you have done. Third, you need to stop trying to make little tiny changes to fix what you have and instead do what I'm suggesting.
In response to Garthor
I'm TRYING to do what you've told me to, but you aren't even being remotely direct!