ID:273816
 
hey guys I ran into a save problem and couldnt fix it so i want your help
code:
mob
Login()
src<<"[src] has logged in!"
while(!src.cansave)
switch(input("What do you want to do?")in list("Load","Delete","Create"))
if("Load")
src.LoadC()
if("Delete")
src.DelC()
if("Create")
src.Create()
..()


client
Del()
..()
src.mob.SaveC()


mob
Write(var/savefile/F)
..()
F["Level"] << Level
F["Exp"] << Exp
F["Nexp"] << Nexp
F["power"] << power
F["maxpower"] << maxpower
F["ki"] << ki
F["maxki"] << maxki
F["strenght"] << strenght
F["defence"] << defence
F["zenni"] << zenni
F["contents"] << contents
F["icon_state"] << icon_state
F["x"] << x
F["y"] << y
F["z"] << z

Read(var/savefile/F)
..()
var/x
var/y
var/z
F["Level"] >> Level
F["Exp"] >> Exp
F["Nexp"] >> Nexp
F["power"] >> power
F["maxpower"] >> maxpower
F["ki"] >> ki
F["maxki"] >> maxki
F["strenght"] >> strenght
F["defence"] >> defence
F["zenni"] >> zenni
F["contents"] >> contents
F["icon_state"] >> icon_state
F["x"] >> x
F["y"] >> y
F["z"] >> z
loc = locate(x,y,z)



mob/var/tmp/cansave=0

mob
proc
SaveC()
if(src.cansave)
var/savefile/F=new("players/[src.key].sav")
Write(F)
LoadC()
if(fexists("players/[src.key].sav"))
var/savefile/F=new("players/[src.key].sav")
Read(F)
src<<"Savefile loaded, welcome back."
src.cansave=1
else
src<<"You have no savefile"
DelC()
if(fexists("players/[src.key].sav"))
var/conf=input("Are you sure you want to delete your savefile?")in list("Yes","No")
if(conf=="Yes")
fdel("players/[src.key].sav")
src<<"Savefile deleted sucessfully"
else
src<<"Deleting cancelled."
else
src<<"You dont have a savefile!"
Create()
if(fexists("players/[src.key].sav"))
src<<"Delete your old savefile first!"
return
var/creating=0
while(!creating)
usr.name=input("Input a name please.")as text|null
creating=1
if(!usr.name) creating=0
src.cansave=1
src<<"Welcome, you have made a new character"
src.icon='races.dmi'
usr.icon_state = input("Which character would you like to be") in list ("Goku","Vegeta")
src.loc=locate(1,1,1)



there is no errors but it wont load.
it worked perfectly until i added in the icon_state save.
I would like to get the icon_state saved with this code because i cant hav everytime i login to hav my icon_state changed
Read and Write should never be used like that as it does not remove references...causing a strange bug with save files.

Instead use << and >> for write/read operations.

i.e F << src

Also, in the read/wright procs you modified, the following lines are autosaved by ..():

F["Level"] >> Level
F["Exp"] >> Exp
F["Nexp"] >> Nexp
F["power"] >> power
F["maxpower"] >> maxpower
F["ki"] >> ki
F["maxki"] >> maxki
F["strenght"] >> strenght
F["defence"] >> defence
F["zenni"] >> zenni
F["contents"] >> contents
F["icon_state"] >> icon_state
In response to Pirion
Sorry I didnt understand you. I am still kinda new to the DM coding like about 2 months coding but still dont know lots of stuff. Can u explain in detail what i did wrong?
In response to Dj dovis
He meant...

mob/verb/Save()
var/savefile/F= new("Save Files/[src.key].sav")
F["Name"] >> name
F["AgeE"] >> age

This is what it's doing. >> means to EXPORT. Basically if you look at the arrows it is opening up to the left meaning data heats to that direction.

F = the File var.

["Name"] is just a var you will use for this command..

mob/proc/Load()
if(fexists("Save Files/[src.key].sav"))
var/savefile/F=file("Save Files/[src.key].sav")
F["Name"] << name
F["AgeE"] << age


Also, if you do not know, you can call the Loading through src.Load() .


Good Luck coding,
Xirre
In response to Xirre
Thanks for your help guys
1 more question about saves when i try to load or create or delete it gives me this stupid thing called safety check in the middle. how would i get rid of that?





EDIT>>>>> It only does that when I am testing the game but another problem has risen. When the servers started When you log in it asks you if you want to create,load or delete lets say i logged in and logged out. the same options wont come to the screen.


(I am hosting the server myself)
just thinking it might be something to do with that
In response to Dj dovis
Dj dovis wrote:
Thanks for your help guys
1 more question about saves when i try to load or create or delete it gives me this stupid thing called safety check in the middle. how would i get rid of that?





EDIT>>>>> It only does that when I am testing the game but another problem has risen. When the servers started When you log in it asks you if you want to create,load or delete lets say i logged in and logged out. the same options wont come to the screen.


(I am hosting the server myself)
just thinking it might be something to do with that


Sounds like a problem in your login(). Read through it and check everything looks normal. Simple debugging like
world << "Create,Load,Delete menu loaded"


Goodluck.
In response to Dj dovis
Add me on my MSN, [email protected] - I will look at your problem and fix it in 5 - 30 minutes. Simple.
In response to Xirre
K i added you