ID:219905
 
(See the best response by Ocean King.)
Code:
client
proc
Load()
var/savefile/load
load = new ("Save Files/[usr.key]")
load["mob"] >> src.mob
load["x"] >> src.mob.x
load["y"] >> src.mob.y
load["z"] >> src.mob.z

Save()
var/savefile/save
save = new ("Save Files/[usr.key]")
save["mob"] << src.mob
save["x"] << src.mob.x
save["y"] << src.mob.y
save["z"] << src.mob.z

Del()
if(!src.mob)return
world << "<font color=#808000 size=1><b>Event - </b><font color=#00db00> [src] has left the server."
src.mob.client.Save()
return ..()
.=..()

mob/player/verb/Save()
set category = "System"
usr << sound (null)
usr.client.Save()
usr << "<font color = yellow size = 1>Saving..."
sleep(22)
usr << "<font color = yellow size = 1>Your game data has been saved successfully."
usr << sound (null)
return


mob/Logout(mob/M)
del(src)


Problem description:
Just a basic saving and loading code that works just fine. My problem is that when the user clicks the load button on the title screen, the user is loaded up, but the title screen music doubles up and my Login()alert("") shows again after they load. I've tried everything and I can't find the problem.

Try using the load on client/New() it's calling twice because the user is logging in loading the save then "starting again" because it's loading a brand new mob.
Client/New()
Send to login screen start music etc
Loads the user is then sent to mob login

Mob/Login()
World << "blah has logged in"


Give it a go and report back.
Another way to solve this problem would be to check if Login() was called by a newly-connected client, or just a change of client.mob.

DM Reference wrote:
One can typically tell if a player is connecting to a fresh mob versus reconnecting to an existing one by testing if the mob's location is null.

Haha.
I tried tinkering around with your suggestions but it's still not working. Unless I'm doing it wrong.
Could you show us your Login Proc?

A.T.H.K wrote:
Try using the load on client/New() it's calling twice because the user is logging in loading the save then "starting again" because it's loading a brand new mob.
> Client/New()
> Send to login screen start music etc
> Loads the user is then sent to mob login
>
> Mob/Login()
> World << "blah has logged in"
>

Give it a go and report back.

Mob and Client to lowercase.
Obviously ... was written on my iPhone ...
Found the issue out:

save["mob"] << src.mob and load["mob"] >> src.mob you're changing the client mob to the mob saved in the savefile, so Login() is re-called making it endless. Remove them and you should be fine.
In response to Ocean King
Ocean King wrote:
Found the issue out:

save["mob"] << src.mob and load["mob"] >> src.mob you're changing the client mob to the mob saved in the savefile, so Login() is re-called making it endless. Remove them and you should be fine.

That Fixed the problem of everything doubling up but now when the player logs in they have no icon.
In response to Ocean King
Ocean King wrote:
Could you show us your Login Proc?

A.T.H.K wrote:
Try using the load on client/New() it's calling twice because the user is logging in loading the save then "starting again" because it's loading a brand new mob.
> > Client/New()
> > Send to login screen start music etc
> > Loads the user is then sent to mob login
> >
> > Mob/Login()
> > World << "blah has logged in"
> >

Give it a go and report back.

Mob and Client to lowercase.

Here is my login
mob
Login()
alert("")
src.title_screen()
density = 1
You need to save their icon. Same way as you do for other stuff.

save["icon"] << src.mob.icon;
load["icon"] >> src.mob.icon;
In response to Ocean King
Ocean King wrote:
Found the issue out:

save["mob"] << src.mob and load["mob"] >> src.mob you're changing the client mob to the mob saved in the savefile, so Login() is re-called making it endless. Remove them and you should be fine.

Removing that and the mob won't load silly suggestion ...



mob/Login()
if(src.loc == null)
alert("")
src.title_screen()
density = 1
else
world << "[src.key] has logged in"
If you save the mob variable and then calling Load() will just make an endless loop. Since you're doing this:

-New Mob
-Called Load()
-Load changed client.mob to a new mob
-So we call mob/Login() again
-New Login() calls again Load()
-Load Changes client mob again
-Login() is begin called again

You need to save the vars separated. Checking if it's loc is null won't help in anything.
My fault.
Best response
I already answered, remove those load["mob"] >>src.client.mob and save["mob"] << src.client.mob and you'll be fixed. If you want to save the icon just do save["icon"] << src.icon, load["icon"] >> src.icon

That fixes the issue reported at first post.
Then you just could save the icon name into the file and then set it at the Load() proc.