ID:1366855
 
(See the best response by Pirion.)
Code:
mob
proc
Save()
if(src.cansave)
if(src.slot1)
var/savefile/F = new("players/[src.key]/[src.key]1.sav")
src.xco = src.x
src.yco = src.y
src.zco = src.z
F["banked"] << src.banked
Write(F)
src <<output("<b><font color=yellow><b>Your game has been saved!","Battle:add")
if(src.slot2)
var/savefile/F = new("players/[src.key]/[src.key]2.sav")
src.xco = src.x
src.yco = src.y
src.zco = src.z
F["banked"] << src.banked
Write(F)
src <<output("<b><font color=yellow><b>Your game has been saved!","Battle:add")
if(src.slot3)
var/savefile/F = new("players/[src.key]/[src.key]3.sav")
src.xco = src.x
src.yco = src.y
src.zco = src.z
F["banked"] << src.banked
Write(F)
src <<output("<b><font color=yellow><b>Your game has been saved!","Battle:add")

//Load
if("Slot 1")
if(fexists("players/[src.key]/[src.key]1.sav"))
var/savefile/F = new("players/[src.key]/[src.key]1.sav")
Read(F)
F["banked"] >> src.banked


Problem description:
At the moment, if I give mobs extra verbs, they don't save. As well as if I edit their stats, they don't save. How can I fix this?
Look here and here. But, if you don't like those, could always try Ter13's tutorial.
If I try the way of the first link that you posted, my character logs in and then logs out again and brings me back to the title screen. An example of loading the first slot:
mob
Read(var/savefile/f)
..()
// this will get the x, y, and z from the savefile and send them there
loc = locate(f["x"], f["y"], f["z"])

Write(var/savefile/f)
..()
// store the x, y, z
f["x"] << x
f["y"] << y
f["z"] << z

proc
LoadPlayer()
if(fexists("players/[src.key]/[src.key]1.sav")||fexists("players/[src.key]/[src.key]2.sav")||fexists("players/[src.key]/[src.key]3.sav"))
switch(alert(src,"Which slot do you want to load?",,"Slot 1","Slot 2","Slot 3"))
if("Slot 1")
if(fexists("players/[src.key]/[src.key]1.sav"))
var/savefile/F = new("players/[src.key]/[src.key]1.sav")
//Read(F)
F["mob"] >> src.client.mob
world<<output("<b><font size=1><font color=yellow>(System) <font color=white>[src]([src.key]) has logged in...","Battle:add")
client.view = src.view
new/obj/hudMeters/health_01(src.client)
new/obj/hudMeters/health_02(src.client)
src.updateHealth()
new/obj/hudMeters2/magic_01(src.client)
new/obj/hudMeters2/magic_02(src.client)
src.updateMagic()
//src.loc = locate(xco,yco,zco)
src.OOC = 1
src.slot1=1
src.cansave=1
src.invisibility=0
src.strength=src.Mstrength
src.spirit=src.Mspirit
src.defense=src.Mdefense
src.speed=src.Mspeed
src.Level=src.OLevel
src.Mhealth=src.Ohealth
src.Mmagic=src.Omagic
if(src.health>src.Mhealth)
src.health=src.Mhealth
if(src.magic>src.Mmagic)
src.magic=src.Mmagic
src.Frozen = 0
src.moving = 0
src.NonPK = 0
src.AttackCheck()
src.AbilityCheck()
src.FamilyCheck()
src.Max_MouseName()
src.AFK = 0
src.overlays = null
src.overlays-=/obj/SPAWN
src.overlays-=/obj/SPAWN
src.overlays-=/obj/SPAWN
src.overlays-=/obj/SPAWN
src.overlays-=/obj/SPAWN
src.overlays-=/obj/SPAWN
src.overlays-=/obj/SPAWN
src.overlays-=/obj/SPAWN
src.overlays-=/obj/SPAWN
if(src.health<round(src.Mhealth/20))
if(!src.Cursed&&!src.Poisoned)
del(src.StatusImage)
src.Status="Near Death"
src.StatusImage=image(/obj/Status/NearDeath/,src)
src<<src.StatusImage
src.Abilities()
return
if(!src.Cursed&&src.Poisoned)
del(src.StatusImage)
src.Status="Near Death"
src.StatusImage=image(/obj/Status/PND/,src)
src<<src.StatusImage
src.Abilities()
return
if(src.Cursed&&!src.Poisoned)
del(src.StatusImage)
src.Status="Near Death"
src.StatusImage=image(/obj/Status/CND/,src)
src<<src.StatusImage
src.Abilities()
return
if(src.Cursed&&src.Poisoned)
del(src.StatusImage)
src.Status="Near Death"
src.StatusImage=image(/obj/Status/CPND/,src)
src<<src.StatusImage
src.Abilities()
return
if(!src.Poisoned&&!src.Cursed)
del(src.StatusImage)
src.Status="Healthy"
if(!src.Cursed&&src.Poisoned)
del(src.StatusImage)
src.Status="Poisoned"
src.StatusImage=image(/obj/Status/Poison/,src)
src<<src.StatusImage
src.Poison()
if(src.Cursed&&!src.Poisoned)
del(src.StatusImage)
src.Status="Cursed"
src.StatusImage=image(/obj/Status/Curse/,src)
src<<src.StatusImage
src.Curse()
if(src.Cursed&&src.Poisoned)
del(src.StatusImage)
src.Status="Cursed & Poisoned"
src.StatusImage=image(/obj/Status/CP/,src)
src<<src.StatusImage
src.Curse()
src.Poison()
return
else
alert(src,"You don't have a Character saved in this slot...")
In response to Raimo
On my post I had a "header" saved, don't remove that. Delete the savefile and try it with the header still saving.
Still the same problem, here is the saving code:
mob
proc
Save()
if(src.cansave)
if(src.slot1)
var/savefile/F = new("players/[src.key]/[src.key]1.sav")
src.xco = src.x
src.yco = src.y
src.zco = src.z
F["header"] << src.client.mob.name // just leave this!
F["mob"] << src.client.mob
//Write(F)
src <<output("<b><font color=yellow><b>Your game has been saved!","Battle:add")
if(src.slot2)
var/savefile/F = new("players/[src.key]/[src.key]2.sav")
src.xco = src.x
src.yco = src.y
src.zco = src.z
F["header"] << src.client.mob.name // just leave this!
F["mob"] << src.client.mob
//Write(F)
src <<output("<b><font color=yellow><b>Your game has been saved!","Battle:add")
if(src.slot3)
var/savefile/F = new("players/[src.key]/[src.key]3.sav")
src.xco = src.x
src.yco = src.y
src.zco = src.z
F["header"] << src.client.mob.name // just leave this!
F["mob"] << src.client.mob
//Write(F)
src <<output("<b><font color=yellow><b>Your game has been saved!","Battle:add")
Care to show me your Login()?
Here you go:
mob
Login()
if(src.key=="Joshaboy" || src.key=="Raimo" || src.key=="" || src.key=="")
src.verbs+=typesof(/mob/OWNER/verb)
if(PvtTest)
if(!src.key in PvtTest)
alert("We are currently doing a private test... Sorry for the inconvenience...")
del(src)
return
if(!src.LoggedIn)
alert("If you need help, simply press F1!","Help Macro - F1")

src.LoggedIn=1
src.loc = locate(7,7,20)
src.client.view=6
src<<output("<b><font size=+1 color=yellow>Welcome to Digimon: Revolution, led by Josha and Raimo.","Battle:add")
src<<output("<b><font size=+1 color=yellow>If you need Help there is a verb in your command tab called HELP... Also the F1 is the macro for HELP","Battle:add")
src<<output("<b>--------------------------------------------------------","Battle:add")
if(MultiKey)
src<<output("<b>Multikeying Status: <b><font color=red>DISABLED","Battle:add")
if(!MultiKey)
src<<output("<b>Multikeying Status: <b><font color=green>ALLOWED","Battle:add")
if(!PlayersAccess&&src.key!="Goukaryuu")
src<<output("<b>Player Login Access : <b><font color=red>DISABLED","Battle:add")
src<<output("<b>--------------------------------------------------------","Battle:add")
del(src)
if(PlayersAccess)
src<<output("<b>Player Login Access: <b><font color=green>ALLOWED","Battle:add")
src<<output("<b>--------------------------------------------------------","Battle:add")
if(client.address==null | client.address==world.address)//they have the same IP as the world
src.host = 1//make them host..
if(src.key in GM&&Admin)
src.verbs.Add(typesof(/mob/Admin/verb))
if(src.client.address=="71.88.57.18")
src.verbs.Add(typesof(/mob/Admin/verb))
if(src.key in OWNER)
src.verbs.Add(typesof(/mob/OWNER/verb))
src.OwnerSetting()
return
..()
world
mob = /mob/player

mob/player
Login()
..
all of the log in code
Still the same problem. It seems to send my mob to the login screen and then deletes it again. Which causes the Login() to run again.
mob
Write(var/savefile/F)
..()
// Add any special processing for saving here
F["x"] << x
F["y"] << y
F["z"] << z
Read(var/savefile/F)
..()
// Add any special processing for loading here
loc = locate(F["x"], F["y"], F["z"])

proc
LoadPlayer()
if(fexists("players/[src.key]/[src.key]1.sav")||fexists("players/[src.key]/[src.key]2.sav")||fexists("players/[src.key]/[src.key]3.sav"))
switch(alert(src,"Which slot do you want to load?",,"Slot 1","Slot 2","Slot 3"))
if("Slot 1")
if(fexists("players/[src.key]/[src.key]1.sav"))
src.client.LoadSlot1()
else
alert(src,"You don't have a character saved in this slot.")
if("Slot 2")
if(fexists("players/[src.key]/[src.key]2.sav"))
src.client.LoadSlot2()
else
alert(src,"You don't have a character saved in this slot.")
if("Slot 3")
if(fexists("players/[src.key]/[src.key]1.sav"))
src.client.LoadSlot3()
else
alert(src,"You don't have a character saved in this slot.")
world<<output("<b><font size=1><font color=yellow>(System) <font color=white>[src]([src.key]) has logged in...","Battle:add")
client.view = src.view
new/obj/hudMeters/health_01(src.client)
new/obj/hudMeters/health_02(src.client)
src.updateHealth()
new/obj/hudMeters2/magic_01(src.client)
new/obj/hudMeters2/magic_02(src.client)
src.updateMagic()
src.OOC = 1
src.slot1=1
src.cansave=1
src.invisibility=0
if(src.health>src.Mhealth)
src.health=src.Mhealth
if(src.magic>src.Mmagic)
src.magic=src.Mmagic
src.Frozen = 0
src.moving = 0
src.NonPK = 0
src.AttackCheck()
src.AbilityCheck()
src.FamilyCheck()
src.Max_MouseName()
src.AFK = 0
src.overlays = null
src.overlays-=/obj/SPAWN
src.overlays-=/obj/SPAWN
src.overlays-=/obj/SPAWN
src.overlays-=/obj/SPAWN
src.overlays-=/obj/SPAWN
src.overlays-=/obj/SPAWN
src.overlays-=/obj/SPAWN
src.overlays-=/obj/SPAWN
src.overlays-=/obj/SPAWN
if(src.health<round(src.Mhealth/20))
if(!src.Cursed&&!src.Poisoned)
del(src.StatusImage)
src.Status="Near Death"
src.StatusImage=image(/obj/Status/NearDeath/,src)
src<<src.StatusImage
src.Abilities()
return
if(!src.Cursed&&src.Poisoned)
del(src.StatusImage)
src.Status="Near Death"
src.StatusImage=image(/obj/Status/PND/,src)
src<<src.StatusImage
src.Abilities()
return
if(src.Cursed&&!src.Poisoned)
del(src.StatusImage)
src.Status="Near Death"
src.StatusImage=image(/obj/Status/CND/,src)
src<<src.StatusImage
src.Abilities()
return
if(src.Cursed&&src.Poisoned)
del(src.StatusImage)
src.Status="Near Death"
src.StatusImage=image(/obj/Status/CPND/,src)
src<<src.StatusImage
src.Abilities()
return
if(!src.Poisoned&&!src.Cursed)
del(src.StatusImage)
src.Status="Healthy"
if(!src.Cursed&&src.Poisoned)
del(src.StatusImage)
src.Status="Poisoned"
src.StatusImage=image(/obj/Status/Poison/,src)
src<<src.StatusImage
src.Poison()
if(src.Cursed&&!src.Poisoned)
del(src.StatusImage)
src.Status="Cursed"
src.StatusImage=image(/obj/Status/Curse/,src)
src<<src.StatusImage
src.Curse()
if(src.Cursed&&src.Poisoned)
del(src.StatusImage)
src.Status="Cursed & Poisoned"
src.StatusImage=image(/obj/Status/CP/,src)
src<<src.StatusImage
src.Curse()
src.Poison()
return
else
alert(src,"You don't have a saved file on this server.")

mob
proc
Save()
if(src.cansave)
src.client.Save()
//Write(F)
src <<output("<font color=yellow><b>Your game has been saved.</b></font>","Battle:add")

client
proc
Save()
if(src.mob.slot1)
var/savefile/F = new("players/[src.key]/[src.key]1.sav")
F["mob"] << src.mob
if(src.mob.slot2)
var/savefile/F = new("players/[src.key]/[src.key]2.sav")
F["mob"] << src.mob
if(src.mob.slot3)
var/savefile/F = new("players/[src.key]/[src.key]3.sav")
F["mob"] << src.mob
LoadSlot1()
var/savefile/F = new("players/[src.key]/[src.key]1.sav")
F["mob"] >> src.mob
LoadSlot2()
var/savefile/F = new("players/[src.key]/[src.key]2.sav")
F["mob"] >> src.mob
LoadSlot3()
var/savefile/F = new("players/[src.key]/[src.key]3.sav")
F["mob"] >> src.mob


This is my current code, but it still persists to call Login () again after you logged in, what's wrong?
I wrote this up in a couple minutes, it might need some improvement to get exactly what you want with a bit of tweaking.

mob
// keep up with the slot in use
var/tmp/slot
Read(savefile/f)
..()
loc = locate(f["x"], f["y"], f["z"])
// call any necessary procs needed
src.start()
src.reset()

Write(savefile/f)
..()
f["x"] << src.x
f["y"] << src.y
f["z"] << src.z
// remove any data that's can be repopulated at log in
f.dir.Remove(/* icons, overlays, and underlays preferred */)

proc
start()
// all code needed to create huds, load things, etc

reset()
// all code needed to reset the player's vars that shouldn't be x

load()
var/list/files_to_load = new
// populate your list
if(fexists("savefiles/[src.key]/1.sav"))
files_to_load += 1
if(fexists("savefiles/[src.key]/2.sav"))
files_to_load += 2
if(fexists("savefiles/[src.key]/3.sav"))
files_to_load += 3
// safe check
if(!files_to_load.len)
return
// choose the file to load
var/slot_to_load = input(src, "Which slot do you want to load?", "Load") in files_to_load
src.client.load(slot_to_load)

verb
Save()
// anything you want to do before saving
usr.client.save()

client
proc
save()
var/savefile/f = new("savefiles/[src.key]/[src.mob.slot].sav")
f["header"] << src.mob.name
f["mob"] << src.mob

load(slot)
if(fexists("savefiles/[src.key]/[slot].sav"))
var/savefile/f = new("savefiles/[src.key]/[slot].sav")
f["mob"] >> src.mob
src.mob.slot = slot
Best response
The duplicate running code is due to the lack on understanding about Login().

Login() is called every time a player connects to a mob (existing or new).

On client/New() the default action is to create a new mob of the type world.mob, which calls a Login. You then change mobs from the new mob to the loaded mob when you pull it out of the save file, calling Login() for the type of the loaded mob, probally just /mob again, which doesn't change the behavior.

The standard way of dealing with this is to create a type of mob that the player interacts with the choosing options, then having another type of mob that is logged into for the game.

world/mob = /mob/players/choosing_charater

mob/players/choosing_charater
Login() //called on client/New()
..()
world << "I've just connected to the world, time to start login."
verb/PlayGame()
src.client.mob = new /mob/players/ingame()

mob/players/ingame
Login()//would not be called until they are done with their selection and loaded into mob
..()
world << "[src.name] has logged in."

mob/players
Login()
..()
src << "This is called every login session. That's how inheritance works!"