ID:157737
 
This is my save/load script, but it won't load their character graphic which is represented by the overworldcharacter variable.

First Time Ran
runtime error: Cannot read null.level
proc name: Write (/mob/Write)
usr: Rail (/mob)
src: Rail (/mob)
call stack:
Rail (/mob): Write(players.sav (/savefile))
Rail (/mob): Logout()

Second Time Ran
runtime error: Cannot create objects of type null.
proc name: Read (/mob/Read)
usr: Rail (/mob)
src: Rail (/mob)
call stack:
Rail (/mob): Read(players.sav (/savefile))
Rail (/mob): Login()

runtime error: Cannot read null.level
proc name: Write (/mob/Write)
usr: Rail (/mob)
src: Rail (/mob)
call stack:
Rail (/mob): Write(players.sav (/savefile))
Rail (/mob): Logout()

runtime error: Cannot read null.loadcharacter
proc name: Login (/mob/Login)
usr: Rail (/mob)
src: Rail (/mob)
call stack:
Rail (/mob): Login()

mob
Write(savefile/SaveFile)
SaveFile.cd = "[usr.ckey]"
SaveFile["name"] << usr.name
SaveFile["level"] << client.level
SaveFile["overworldcharacter"] << client.overworldcharacter
Read(savefile/SaveFile)
SaveFile.cd = "/"
if(usr.ckey in SaveFile.dir)
SaveFile.cd = "[usr.ckey]"
SaveFile["name"] >> usr.name
SaveFile["level"] >> client.level
SaveFile["overworldcharacter"] >> client.overworldcharacter
usr.icon = 'omovement.dmi'
usr.icon_state = client.overworldcharacter
usr.Move(locate(21,7,1))
new/obj/hud/default(usr.client)
new client.overworldavatar(usr.client)
client.loadcharacter = 1
world << output("1st Part","chat")
else
client.loadcharacter = 2
world << output("1st Part Failed","chat")
icon = 'movement.dmi'
Login()
world << output("Logged In","chat")
Read(SaveFile)
do
sleep(2)
while(client.loadcharacter == 0)
if(client.loadcharacter == 2)
gilist += /obj/battle/Gi_Light
gilist += /obj/battle/Gi_Medium
gilist += /obj/battle/Gi_Dark
gilist += /obj/battle/Gi2_Light
gilist += /obj/battle/Gi2_Medium
gilist += /obj/battle/Gi2_Dark
gilist += /obj/battle/Gi3_Light
gilist += /obj/battle/Gi3_Medium
gilist += /obj/battle/Gi3_Dark
hairlist += /obj/battle/Light
hairlist += /obj/battle/Medium
hairlist += /obj/battle/Dark
client.nocontrol = 1
usr.Move(locate(9,3,2))
usr.dir = 1
winshow(usr,"CreateCharacter",1)
do
sleep(2)
if(client.hair == 0)
if(client.skincolor == 0)
usr.overlays -= hairlist
usr.overlays += /obj/battle/Light
client.overworldavatar = /obj/hud/avatars/Light
if(client.skincolor == 1)
usr.overlays -= hairlist
usr.overlays += /obj/battle/Medium
client.overworldavatar = /obj/hud/avatars/Medium
if(client.skincolor == 2)
usr.overlays -= hairlist
usr.overlays += /obj/battle/Dark
client.overworldavatar = /obj/hud/avatars/Dark
if(client.gicolor == 0)
if(client.skincolor == 0)
usr.overlays -= gilist
usr.overlays += /obj/battle/Gi_Light
client.overworldcharacter = "Gi_Light"
if(client.skincolor == 1)
usr.overlays -= gilist
usr.overlays += /obj/battle/Gi_Medium
client.overworldcharacter = "Gi_Medium"
if(client.skincolor == 2)
usr.overlays -= gilist
usr.overlays += /obj/battle/Gi_Dark
client.overworldcharacter = "Gi_Dark"
if(client.gicolor == 1)
if(client.skincolor == 0)
usr.overlays -= gilist
usr.overlays += /obj/battle/Gi2_Light
client.overworldcharacter = "Gi2_Light"
if(client.skincolor == 1)
usr.overlays -= gilist
usr.overlays += /obj/battle/Gi2_Medium
client.overworldcharacter = "Gi2_Medium"
if(client.skincolor == 2)
usr.overlays -= gilist
usr.overlays += /obj/battle/Gi2_Dark
client.overworldcharacter = "Gi2_Dark"
if(client.gicolor == 2)
if(client.skincolor == 0)
usr.overlays -= gilist
usr.overlays += /obj/battle/Gi3_Light
client.overworldcharacter = "Gi3_Light"
if(client.skincolor == 1)
usr.overlays -= gilist
usr.overlays += /obj/battle/Gi3_Medium
client.overworldcharacter = "Gi3_Medium"
if(client.skincolor == 2)
usr.overlays -= gilist
usr.overlays += /obj/battle/Gi3_Dark
client.overworldcharacter = "Gi3_Dark"
world << output("2nd Part Failed","chat")
while(client.submit <> 1)
usr.name = input("Character Name") as text
client.hud = new/obj/hud/default(usr.client)
client.hudavatar = new client.overworldavatar(usr.client)
fullhealth()
usr.overlays = 0
usr.icon = 'omovement.dmi'
usr.icon_state = client.overworldcharacter
usr.Move(locate(21,7,1))
client.nocontrol = 0
client.level = 10
world << output("2nd Part","chat")
Logout()
Write(SaveFile)
..()


Help?
Some errors don't seem to be from here, adding debug would help too.

Do you have any IM?
In response to Ripiz
Sorry, those were my old runtime errors before I changed the variables, fixed it above.

I can be contacted at [email protected]
The client is gone by the time Logout() is called, so trying to access its variables is futile. You need to be calling the save routines from client/Del() instead.

You also need to not use usr in procs.

You also need to not be messing with cd like that in Read() and Write(). The cd is going to already be set to the directory the mob is being saved into (savefile directory, not hard drive), and if you screw with it then trying to save multiple mobs in the same savefile will REALLY mess things up.

You also need to nuke that monstrosity, as there is nothing done correctly there that I can see. It really needs to just be done over from scratch. Here's how to start:

client
New()
if(fexists("[ckey].save")
var/savefile/F = new("[ckey].save")
F["mob"] >> mob
Del()
var/savefile/F = new("[ckey].save")
F["mob"] << mob

mob
Write(var/savefile/F)
..()
//special save handling goes here
Read(var/savefile/F)
//special load handling goes here