ID:142848
 
Code:
#include <deadron/characterhandling>


client
base_num_characters_allowed = 5

world

mob = /mob/creating_character

mob/base_save_location = 0



mob/creating_character
base_save_allowed = 0 // If player quits before choosing, don't want to save this mob.

Login()
// Spawn here to avoid problems with calling prompts during login.
spawn()
src.CreateCharacter()

proc/CreateCharacter()

var/prompt_title = "New Character"
var/help_text = "What do you want to name the character?"
var/default_value = key
var/char_name = input(src, help_text, prompt_title, default_value) as null|text
char_name = html_encode(char_name)
if(length(char_name)>20)
char_name = null
alert("Names must be under 21 characters long.")
if (!char_name)

client.base_ChooseCharacter()
return

// Make sure there isn't already a character named that.
// Character names are stored as ckey, so get the ckey version of the name.
var/ckey_name = ckey(char_name)
var/list/characters = client.base_CharacterNames()
if (characters.Find(ckey_name))
alert("You already have a character named that! Please choose another name.")
src.CreateCharacter()
return
var/char_class
var/list/classes = list("Berserker","Demon Lord","Dragoon","Gaurd","Gladiator","Golem","Healer","Knight","Mage","Nomad","Ogre","Rogue","Warlock")
help_text = "What class?"
default_value = "Warrior"
char_class = input(src, help_text, prompt_title, default_value) in classes


var/mob/new_mob



// Okay we have enough information, so it's time to create the character and switch the player to it.

switch(char_class)
if("Berserker")
usr.hp = 20
usr.atk = 5
usr.def = 0
usr.str = 5
usr.dex = 15
usr.gold = 10
usr.icon = 'Berserker.dmi'
usr.contents += new/obj/weapons/Axe
if("Dragoon")
usr.hp = 15
usr.atk = 10
usr.def = 1
usr.str = 10
usr.dex = 5
usr.icon = 'Black Dragon.dmi'
if("Demon Lord")
usr.hp = 10
usr.atk = 4
usr.def = 0
usr.str = 4
usr.dex = 10
usr.icon = 'Demon Lord.dmi'
usr.gold = 5
usr.contents += new/obj/weapons/Longsword
usr.contents += new/obj/armour/demon_plate
if("Mage")
usr.hp = 10
usr.atk = 2
usr.def = 0
usr.gold = 40
usr.spell = 1
usr.mp = 40
usr.mmp = 40
usr.str = 3
usr.dex = 10
usr.icon = 'Mage.dmi'
usr.contents += new/obj/weapons/Quarterstaff
usr.contents += new/obj/armour/leather
if("Gaurd")
usr.hp = 15
usr.atk = 3
usr.def = 7
usr.gold = 20
usr.str = 5
usr.dex = 12
usr.icon = 'Gaurd.dmi'
usr.contents += new/obj/weapons/Hammer
usr.contents += new/obj/armour/plate
if("Gladiator")
usr.hp = 15
usr.atk = 5
usr.def = 2
usr.gold = 50
usr.str = 10
usr.dex = 13
usr.icon = 'Gladiator.dmi'
usr.contents += new/obj/weapons/Flail
usr.contents += new/obj/armour/chain_mail
if("Golem")
usr.hp = 20
usr.atk = 2
usr.def = 10
usr.str = 8
usr.dex = 1
usr.icon = 'Golem.dmi'
if("Healer")
usr.hp = 30
usr.atk = 2
usr.def = 1
usr.gold = 30
usr.spell = 1
usr.mp = 20
usr.mmp = 20
usr.str = 4
usr.dex = 14
usr.icon = 'Healer.dmi'
usr.contents += new/obj/weapons/Dagger
usr.contents += new/obj/armour/leather
if("Knight")
usr.hp = 15
usr.atk = 5
usr.def = 2
usr.str = 12
usr.dex = 7
usr.icon = 'Knight.dmi'
usr.contents += new/obj/weapons/Longsword
usr.contents += new/obj/armour/plate
if("Nomad")
usr.hp = 15
usr.atk = 4
usr.def = 5
usr.gold = 10
usr.str = 10
usr.dex = 20
usr.icon = 'Nomad.dmi'
usr.contents += new/obj/weapons/Short_Sword
usr.contents += new/obj/armour/studded_leather
if("Ogre")
usr.hp = 20
usr.atk = 8
usr.def = -2
usr.gold = 5
usr.str = 15
usr.dex = 4
usr.icon = 'Ogre.dmi'
usr.contents += new/obj/weapons/Axe
usr.contents += new/obj/armour/heavy_plate
if("Ranger")
usr.hp = 20
usr.atk = 5
usr.def = 0
usr.gold = 20
usr.str = 4
usr.dex = 35
usr.icon = 'Rogue.dmi'
usr.contents += new/obj/weapons/Scimitar
usr.contents += new/obj/armour/leather
if("Rogue")
usr.hp = 10
usr.atk = 6
usr.def = 0
usr.gold = 45
usr.str = 4
usr.dex = 30
usr.icon = 'Rogue.dmi'
usr.contents += new/obj/weapons/Dagger
usr.contents += new/obj/armour/studded_leather
if("Samurai")
usr.hp = 15
usr.atk = 8
usr.def = 0
usr.gold = 15
usr.str = 6
usr.dex = 15
usr.icon = 'Rogue.dmi'
usr.contents += new/obj/weapons/Scimitar
usr.contents += new/obj/armour/plate
if("Skirmisher")
usr.hp = 10
usr.atk = 4
usr.def = 1
usr.gold = 10
usr.str = 3
usr.dex = 35
usr.icon = 'Rogue.dmi'
usr.contents += new/obj/weapons/Dagger
usr.contents += new/obj/armour/studded_leather
if("Warlock")
usr.hp = 10
usr.atk = 3
usr.def = 1
usr.gold = 50
usr.spell = 1
usr.mp = 30
usr.mmp = 30
usr.str = 5
usr.dex = 10
usr.icon = 'Sage.dmi'
usr.contents += new/obj/weapons/Quarterstaff
usr.contents += new/obj/armour/leather

// Set the attributes.
new_mob.name = char_name


// Now switch the player client over to the new mob and delete myself since I'm no longer needed.
src.client.mob = new_mob
var/turf/first_location = locate(10,3,1)
new_mob.Move(first_location)
del(src)

mob
Login()
..()

// This is just here for this sample, to make it clear which mob you've logged into.
/*switch(src.key)
if("Xerse", "ManeBass", "Mmbah")
world << "\blue <b> [usr] has joined all; bow to \his mighty power!"*/


// This is just here for this sample, to make it clear which mob you've logged into.


Write(savefile/F)
// This is sample code that keeps track of the player's last position on the map.
// Their last position is stored when the mob is saved, then reinstated when the mob
// is read in.

// First, call the default Write() behavior for mobs.
..()

// Now, if we have a map, remember their last location.
if (world.maxx)
F["last_x"] << x
F["last_y"] << y
F["last_z"] << z

Read(savefile/F)
// Call the default Read() behavior for mobs.
..()

// Now, if we have a map, put them back on the map in their last location.
if (world.maxx)
var/last_x
var/last_y
var/last_z
F["last_x"] >> last_x
F["last_y"] >> last_y
F["last_z"] >> last_z
loc = locate(last_x, last_y, last_z)
mob
Login()
..()

// This is just here for this sample, to make it clear which mob you've logged into.
sample_report()


verb
save_me()
// This demonstrates verb saving and how to manually save the mob whenever you want..
// This proc gets added and saved as a verb only if add_verb is called by the player.
src.client.base_SaveMob()
src << "\red You have been saved."
proc
sample_report()
src << "<BR><BR>"
src << "\blue You are [name]."
src << "\blue You are level [lvl]."


Problem description:
That is my entire source based off the "Rise of Heros" release.
It just doesn't work
I am only riping this because I, nor any of my coders know how to create a save code... If someone could help me, that would be great!
Ask your coders to read the DM guide, especially chapter 12

The code example you give looks like it was written based on stuff in that chapeter. So reading it will give them a good explanation of the code.

They should read the rest of the guide too, so they can notice some problems in the code, like where mob is indented and if it wasn't like how there are 2 Login()'s declared. Stuff like that is impossible for coders to figure out without at least learning the basics.

Good luck.
In response to Traztx
yea I read so did they, not much help well here is what i now got...

/********
Character saving example.

This demo uses Deadron's CharacterHandling library,
which automatically handles saving and loading player mobs.
Player mobs are saved when the player logs out.

This demo saves the player and their last location on the map.

The library is a part of BaseCamp, Deadron's game infrastructure system.

Full documentation for the library can be found by double-clicking
on Lib/Deadron.CharacterHandling, then viewing the characterhandling.dm file.

If you have questions or suggestions, please email ron@deadron.com.

BaseCamp: From here you can reach Everest!
***********/

#include <deadron/characterhandling>



// How many characters is a player allowed to have?
client/base_num_characters_allowed = 3


/***
Turning off automatic features
------------------------------
By default, the CharacterHandling library automatically loads and saves characters
for you. There are settings that will turn off the automatic behavior if you wish.

client/base_autoload_character = 0
----------------------------------
This turns off auto-loading when a player logs in.
Whenever you do want the player to load a character, call that player's
client.base_ChooseCharacter() function.

client/base_autosave_character = 0
----------------------------------
This turns off auto-saving when a player logs out.
If you turn off auto-saving or also want to save at other times, use
the player's client.base_SaveMob() function, as shown in the save_me()
verb below.

client/base_autodelete_mob = 0
------------------------------
This stops the library from deleting the player's mob after they log out.
Without this, the mob will stay in the game until you delete it yourself.

mob/base_save_location = 0
------------------------------
This turns off the location saving, which means you will need to manually
place the mob after it is read in from the savefile.

Uncomment one or more of the following lines to turn off a feature.
***/

// client/base_autoload_character = 0
// client/base_autosave_character = 0
// client/base_autodelete_mob = 0
// mob/base_save_location = 0


/***
Specifying the mob type
-----------------------
When a new character needs to be created, the CharacterHandling library
creates a mob of type world.mob and logs the player into it.

You can choose any mob type and anything you want with this mob.

This example sets the default mob to /mob/creating_character.
When the player is logged into the creating_character class, they are asked
questions about their character's attributes. When they are done, a new
mob is created with those attributes and the player is logged into it.

This is just one possible way you could do things. It's provided as an example.
None of it is required for the library to work.
***/

world/mob = /mob/creating_character



/***********
Example character creation
--------------------------
The code below gives an example of setting up a character.
This is just to give you ideas for how you can do it yourself.
************/

mob/creating_character
base_save_allowed = 0 // If player quits before choosing, don't want to save this mob.

Login()
// Spawn here to avoid problems with calling prompts during login.
spawn()
src.CreateCharacter()

proc/CreateCharacter()
// In this case, the code creates a /mob/human or /mob/ogre with the specified attributes.

// Get the character information from them. (You would probably want to do with this a browser page.)
var/prompt_title = "New Character"
var/help_text = "What do you want to name the character?"
var/default_value = key
var/char_name = input(src, help_text, prompt_title, default_value) as null|text

if (!char_name)
// Guess they don't want to create a new character after all, so send them to choose a character.
client.base_ChooseCharacter()
return

// Make sure there isn't already a character named that.
// Character names are stored as ckey, so get the ckey version of the name.
var/ckey_name = ckey(char_name)
var/list/characters = client.base_CharacterNames()
if (characters.Find(ckey_name))
alert("You already have a character named that! Please choose another name.")
src.CreateCharacter()
return

var/list/classes = list("Cop","Nurse","Berserker","Demon Lord","Dragoon","Gaurd","Gladiator","Golem","Healer","Knight","Mage","Nomad","Ogre","Rogue","Warlock")
help_text = "Which class would you like to be?"
default_value = "Cop"
var/char_class = input(src, help_text, prompt_title, default_value) in classes

// Okay we have enough information, so it's time to create the character and switch the player to it.
var/mob/new_mob
switch(char_class)
if ("Cop") new_mob = new /mob/cop()
if ("Nurse") new_mob = new /mob/nurse()
if ("Berserker") new_mob = new /mob/Berserker()
if ("Demon Lord") new_mob = new /mob/Demon_Lord()
if ("Dragoon") new_mob = new /mob/Dragoon()
if ("Guard") new_mob = new /mob/Guard()
if ("Gladiator") new_mob = new /mob/Gladiator()
if ("Golem") new_mob = new /mob/Golem()
if ("Healer") new_mob = new /mob/Healer()
if ("Knight") new_mob = new /mob/Knight()
if ("Mage") new_mob = new /mob/Mage()
if ("Nomad") new_mob = new /mob/Nomad()
if ("Ogre") new_mob = new /mob/Ogre()
if ("Rogue") new_mob = new /mob/Rogue()
if ("Warlock") new_mob = new /mob/Warlock()

// Set the attributes.
new_mob.name = char_name

// Now switch the player client over to the new mob and delete myself since I'm no longer needed.
src.client.mob = new_mob
var/turf/first_location = locate(1, 1, 1)
new_mob.Move(first_location)
del(src)

mob
Login()
..()

// This is just here for this sample, to make it clear which mob you've logged into.
sample_report()


verb
add_save_verb()
// Adds save_me verb to the mob, to show that verb saving works.
src.verbs += /mob/proc/save_me

remove_save_verb()
src.verbs -= /mob/proc/save_me

proc
sample_report()
src << "<BR><BR>"
src << "\blue You are [name]."
src << "\blue Your class is [type]."

save_me()
// This demonstrates verb saving and how to manually save the mob whenever you want..
// This proc gets added and saved as a verb only if add_verb is called by the player.
src.client.base_SaveMob()
src << "\red You have been saved."

mob/cop

mob/nurse
mob/Berserker
icon = 'Berserker.dmi'
mob/Dragoon
hp = 15
atk = 10
def = 1
str = 10
dex = 5
icon = 'Black Dragon.dmi'
mob/Demon_Lord
hp = 10
atk = 4
def = 0
str = 4
dex = 10
icon = 'Demon Lord.dmi'
gold = 5
contents += new/obj/weapons/Longsword
contents += new/obj/armour/demon_plate
mob/Mage
hp = 10
atk = 2
def = 0
gold = 40
spell = 1
mp = 40
mmp = 40
str = 3
dex = 10
icon = 'Mage.dmi'
contents += new/obj/weapons/Quarterstaff
contents += new/obj/armour/leather
mob/Gaurd
hp = 15
atk = 3
def = 7
gold = 20
str = 5
dex = 12
icon = 'Gaurd.dmi'
contents += new/obj/weapons/Hammer
contents += new/obj/armour/plate
mob/Gladiator
hp = 15
atk = 5
def = 2
gold = 50
str = 10
dex = 13
icon = 'Gladiator.dmi'
contents += new/obj/weapons/Flail
contents += new/obj/armour/chain_mail
mob/Golem
hp = 20
atk = 2
def = 10
str = 8
dex = 1
icon = 'Golem.dmi'
mob/Healer
hp = 30
atk = 2
def = 1
gold = 30
spell = 1
mp = 20
mmp = 20
str = 4
dex = 14
icon = 'Healer.dmi'
contents += new/obj/weapons/Dagger
contents += new/obj/armour/leather
mob/Knight
hp = 15
atk = 5
def = 2
str = 12
dex = 7
icon = 'Knight.dmi'
contents += new/obj/weapons/Longsword
contents += new/obj/armour/plate
mob/Nomad
hp = 15
atk = 4
def = 5
gold = 10
str = 10
dex = 20
icon = 'Nomad.dmi'
contents += new/obj/weapons/Short_Sword
contents += new/obj/armour/studded_leather
mob/Ogre
hp = 20
atk = 8
def = -2
gold = 5
str = 15
dex = 4
icon = 'Ogre.dmi'
contents += new/obj/weapons/Axe
contents += new/obj/armour/heavy_plate
mob/Ranger
hp = 20
atk = 5
def = 0
gold = 20
str = 4
dex = 35
icon = 'Rogue.dmi'
contents += new/obj/weapons/Scimitar
contents += new/obj/armour/leather
mob/Rogue
hp = 10
atk = 6
def = 0
gold = 45
str = 4
dex = 30
icon = 'Rogue.dmi'
contents += new/obj/weapons/Dagger
contents += new/obj/armour/studded_leather
mob/Samurai
hp = 15
atk = 8
def = 0
gold = 15
str = 6
dex = 15
icon = 'Rogue.dmi'
contents += new/obj/weapons/Scimitar
contents += new/obj/armour/plate
mob/Skirmisher
hp = 10
atk = 4
def = 1
gold = 10
str = 3
dex = 35
icon = 'Rogue.dmi'
contents += new/obj/weapons/Dagger
contents += new/obj/armour/studded_leather
mob/Warlock
hp = 10
atk = 3
def = 1
gold = 50
spell = 1
mp = 30
mmp = 30
str = 5
dex = 10
icon = 'Sage.dmi'
contents += new/obj/weapons/Quarterstaff
contents += new/obj/armour/leather