ID:159778
 
<dm><dm><dm>How can I make all items save where there are and what your holding.

mob
proc
//----------------------------------//
CreateChar(mob/M) // The char creation function
//----------------------------------//



//----------------------//
usr << "Charecter created" // debug msg
//----------------------//

usr.loc = locate(1,1,1) // spawn the character to 1,1 on map #1
usr.sight = 0 // make it so the character can see
usr.SaveChar() // Auto-Save the new char for just in case game crashes.
..()

SaveChar() // The proc that saves your character.
var/savefile/F = new("players/[src.ckey].sav") // define the save file and create it
F["name"] << name // Outputs the characters name into the savefile list
F["X"] << src.x // Outputs the char's X coordinate into the list
F["Y"] << src.y // Outputs the char's Y coordinate into the list
F["Z"] << src.z // Outputs the char's Z coordinate into the list
F["Mob"] << usr.client.mob // Outputs ALL of the character (var's, etc) into the list

verb
Save()
usr.SaveChar() // Make a call to the character's saving proc
usr << "Your character has been saved." // Inform the player that he's been saved.



This is what I have so far for my save








turf/LoadChar
icon = 'title.dmi' // load png
icon_state = "load"
Click()
if(fexists("players/[usr.ckey].sav")) // check to see if the character has a savefile
usr.LoadCharacter() // Make a call to load the character

//----------------------------------//
world << "Welcom back [usr.name]!" // Announce to the world
// that the user logged in
//----------------------------------//

usr << "Welcome back to the game!" // Welcome the player
return ..()
else
alert("You don't HAVE an old character here, or it isn't found in our databases!")
// Uh oh! No player file found when they clicked Load!
return ..()
..()




And this is my load

And sorry if It doesnt show up in DM code format, Im a little new to this.
</<></<></<></<></< >
Oh and I forgot the X,Y,Z loading part



</DM>

mob
proc
LoadCharacter() // The load character proc
var/savefile/F = new("players/[src.ckey].sav") // define the location of the save file
var/X // Defines a temporary X variable
var/Y // Defines a temporary Y variable
var/Z // Defines a temporary Z variable
var/mob/newmob = new() // Initialize a new mob
F["name"] >> name // Load the name from the list into the character's name
F["X"] >> X // Load the X variable from the savefile to the temporary X variable
F["Y"] >> Y // Load the Y variable from the savefile to the temporary Y variable
F["Z"] >> Z // Load the Z variable from the savefile to the temporary Z variable
F["Mob"] >> newmob // Load all the mob data into the initialized mob
newmob.loc = locate(X,Y,Z) // Move the initialized mob to the last saved location
newmob.client = src.client // Set the mob's client to players client

</DM>
Hillwood wrote:
How can I make all items save where there are and what your holding.



</DM>
mob
proc
//----------------------------------//
CreateChar(mob/M) // The char creation function
//----------------------------------//



//----------------------//
usr << "Charecter created" // debug msg
//----------------------//

usr.loc = locate(1,1,1) // spawn the character to 1,1 on map #1
usr.sight = 0 // make it so the character can see
usr.SaveChar() // Auto-Save the new char for just in case game crashes.
..()

SaveChar() // The proc that saves your character.
var/savefile/F = new("players/[src.ckey].sav") // define the save file and create it
F["name"] << name // Outputs the characters name into the savefile list
F["X"] << src.x // Outputs the char's X coordinate into the list
F["Y"] << src.y // Outputs the char's Y coordinate into the list
F["Z"] << src.z // Outputs the char's Z coordinate into the list
F["Mob"] << usr.client.mob // Outputs ALL of the character (var's, etc) into the list

verb
Save()
usr.SaveChar() // Make a call to the character's saving proc
usr << "Your character has been saved." // Inform the player that he's been saved.
</DM>


This is what I have so far for my save




</DM>



turf/LoadChar
icon = 'title.dmi' // load png
icon_state = "load"
Click()
if(fexists("players/[usr.ckey].sav")) // check to see if the character has a savefile
usr.LoadCharacter() // Make a call to load the character

//----------------------------------//
world << "Welcom back [usr.name]!" // Announce to the world
// that the user logged in
//----------------------------------//

usr << "Welcome back to the game!" // Welcome the player
return ..()
else
alert("You don't HAVE an old character here, or it isn't found in our databases!")
// Uh oh! No player file found when they clicked Load!
return ..()
..()

</DM>


And this is my load

And sorry if It doesnt show up in DM code format, Im a little new to this.

to make it in dm format use
 CODE HERE


and there's an specific reason to not use Write(F) and Read(F) for loadin and saving?


mob/Player/var/list/SavedVerbs // a list to save the verbs externally
mob/Player
proc
Save()
var/savefile/F = new("saves/[src.key].sav")
src.SavedVerbs = src.verbs //Verbs aren't saved, so you gotta save it in another list
src.xco = src.x //position isn't saved, so you gotta save it in another car
src.yco = src.y // same here
src.zco = src.z //and here
Write(F) //Wirte all the src's variables using Write()


That's for saving and for loading

mob/Player
proc
Load()
if(fexists("saves/[src.key].sav"))
var/savefile/F = new("saves/[src.key].sav")
Read(F) // read all variables saved on F
verbs+=SavedVerbs //Once the vars are readed, get the verbs from the list
loc=locate(xco,yco,zco) //and locate the mob


that way overlays and content are saved, but if you want to do it in the other way, i think
F["Items"] << contents
F["Overlays"]<< overlays

should work


(with items and "what you are holding" i guess you mean contents (used as inventory) and overlays)




By the way, im not a great developer, and i still learning, so i dont get you for sure this is the easiest fastest, more efficient way to do things, i just know it works XD


In response to Frolik
Ok thanks, man Yah the DM part i put the / in the first dm code input and the second, thats why it didnt work. Thanks for correcting that. ok thanks ill touch my code up. You were a big help.