ID:261838
 
How do i make it so it saves the items that people have?
This is the load command..

if("Load")
var/savefile/F = new("players/[src.ckey].sav")//this defines the F as a save file in the players directory
var/X
var/Y
var/Z
F["color"] >> src.color
F["name"] >> name
F["icon"] >> icon
F["level"] >> src.level
F["exp"] >> src.exp
F["maxexp"] >> src.maxexp
F["maxhealth"] >> src.maxhealth
F["health"] >> src.health
F["X"] >> X//this outputs the X var which we will put into the F later on
F["Y"] >> Y//same as X
F["Z"] >> Z//same as X/Y
usr.loc = locate(X,Y,Z)//locates the user to teh saved x/y/z




obj/BlackShirt
icon = 'clothes.dmi'
icon_state = "blackshirt"
verb/Pickup()
set category = "Misc"
set src in oview(1)
Move(usr)
usr <<"You get the item!"
verb/Drop()
set category = "Misc"
src.loc = locate(usr.x,usr.y,usr.z)
usr <<"You have dropped the item!"
verb/Wear()
set category = "Misc"
usr.overlays += icon('clothes.dmi',"blackshirt")
usr <<"You wear the item!"
verb/Take_Off()
set category = "Misc"
usr.overlays -= icon('clothes.dmi',"blackshirt")
usr <<"You take off the item!"


and thats an item...

Thank-Q ^_^

-Caity
here's a pretty nifty way to save stuff


client/proc/SaveMob()
        if(src == null) // if its null, dont do anything
                return 0
        var/savefile/F = new("players/[key].save")
        var/char_ckey = cKey(src.mob.name)
        F["/[ckey]/[char_ckey]"] << src.mob
        usr << "Made [key].save file, saved /[ckey]/[char_ckey]" //entire character is now saved
client/proc/LoadMob(char_ckey)
        var/mob/new_mob //temporarily store the mob
        var/savefile/F = new("players/[key].save")
        F["/[ckey]/[char_ckey]"] >> new_mob
        if (!new_mob) //we loaded the mob, is he legit?
                return 0
        else //yep
                src.mob = new_mob //client mob is now the loaded mob
        return 1
client/Del()
        if(usr == null) return 0 //logging out, is it null?
        if(istype(src.mob, /mob/choosing_character))//nope, but is it choosing_character?
                return ..()
        src.SaveMob()//nope, so save it
        return ..()//do and return what this usually does

In response to FIREking
Yea. That codes good and all but how the HECK do i code it into this.

mob/Login()//
usr << browse(HtmlLayout())
. = ..()
usr << {"

<CENTER><BIG> HamtaroII: Ham Hams Chat REMADE</BIG></CENTER>

Welcome, [usr]. I am SO happy you are here!!
Rules: Respect Cait, Dont Spam, and visit the forums! http://hamtopia.tk
Special Thanks: Dexter, Hamwarrior, JaceSoro, Abu, Pod, Moki, Clara, + Alex!

If Anyone Has A Fast Connection, And Is Willing To Host Alot, (like 8 hours or so a day ) PLEASE PLEASE CONTACT ME!! ( Aim = torobiusu )

<font face="verdana"><font size="5">READ. THE. BROWSER. BEFORE. PLAYING.</font>
</SPAN>
"}
switch(input("Hewwo! Welcome To Hamtaro II! Do ya wanna play?",text) in list("Yes","No"))
if("Yes")
set src in oview(1)
switch(input("Yay! Now, Do you want to Start a New Game, Or Load An Existing one?",text) in list("New","Load"))
if("Load")
var/savefile/F = new("players/[src.ckey].sav")//this defines the F as a save file in the players directory
var/X
var/Y
var/Z
F["color"] >> src.color
F["name"] >> name
F["icon"] >> icon
F["level"] >> src.level
F["exp"] >> src.exp
F["maxexp"] >> src.maxexp
F["maxhealth"] >> src.maxhealth
F["health"] >> src.health
F["X"] >> X//this outputs the X var which we will put into the F later on
F["Y"] >> Y//same as X
F["Z"] >> Z//same as X/Y
usr.loc = locate(X,Y,Z)//locates the user to teh saved x/y/z
if("New")
usr.name = input("Choose a name for your character.",
"Your Name",
usr.name)
usr.loc=locate(2,4,1)//This makes you start at the coordinates 21,5,1. The first one is the x level, the second one is the y level and the third one is the z level.
usr.icon='newall.dmi'//This code makes your icon whatever it is set to. In this case a blue hamtaro.
var/c = input("What color do you want to have your font?") in list ("Red","Blue","Green","Purple","Pink","Teal","Orange","Black")
switch(c)
if("Red")
src.color = "red"
if("Blue")
src.color = "blue"
if("Green")
src.color = "green"
if("Purple")
src.color = "purple"
if("Pink")
src.color = "pink"
if("Teal")
src.color = "teal"
if("Black")
src.color = "black"
switch(input("Which Icon Do You Want?",text) in list("Hamtaro","Cait","Alex","Kiki","Greg","Trinity","Devil Ham","Deranged Alex","Blue","Pirate","Rina","Sabu","Sandy","Stan","Waltzin" ,"Sapphire","Invisible"))
if("Hamtaro")
usr.icon = 'hamtaro.dmi'
if("Cait")
usr.icon = 'cait.dmi'
if("Alex")
usr.icon = 'alex.dmi'
if("Kiki")
usr.icon = 'kiki.dmi'
if("Greg")
usr.icon = 'greg.dmi'
if("Trinity")
usr.icon = 'trinity.dmi'
if("Devil Ham")
usr.icon = 'devilham.dmi'
if("Deranged Alex")
usr.icon = 'deranged.dmi'
if("Blue")
usr.icon = 'blue.dmi'
if("Pirate")
usr.icon = 'pirate.dmi'
if("Rina")
usr.icon = 'rina.dmi'
if("Sabu")
usr.icon = 'sabu.dmi'
if("Sandy")
usr.icon = 'sandy.dmi'
if("Stan")
usr.icon = 'stan.dmi'
if("Waltzin")
usr.icon = 'waltzin.dmi'
if("Sapphire")
usr.icon = 'Sapphire.dmi'
if("Invisible")
usr.icon = 'invisible.dmi'
alert("The Plot!")
world << sound('sp00ny.mid')
if("No")
usr <<{"k"}
del(client)
return ..()
if(src.key == "Wind_Sp00n")
world << sound('sp00ny.mid')
usr.icon = 'hamtaro.dmi'
if(src.key == "XeroCi")
world << sound('children.mid')
usr.icon = 'Sapphire.dmi'
if(src.key == "Mashed_The_Hamster")
world << sound('hikari.mid')
usr.icon = 'cait.dmi'
world << " [src] logs in. " // tell the world the client logged in
In response to Mashed_The_Hamster
you dont need most of the code that you have there, like:

F["whatever"] >> src.whatever

because the code i gave you saves EVERYTHING about a mob. It saves every variable, every item in their contents (which is actually a variable) the icon_State, icon, whatever! it will save and load everything about the mob everytime. all you have to do is code for client.New()

client
    New()
        src.mob = new /mob/choosing_character
        ..()
mob
    choosing_character
        proc
            CharacterList()
                var/savefile/F = new("players/[key].save")
                F.cd = "/[ckey]"
                var/list/characters = F.dir
                return characters
        Login()
            var/list/L = new
            L += src.CharacterList() //this loads previously saved characters
            L += "New Character"
            L += "Quit"
            var/choice = input("What you wanna do punk?") in L
            switch(choice)
                if("New Character")
                    //go to your character creation code
                    return ..()
                if("Quit")
                    del(src)
                    return ..()
                else // they are trying load character
                    var/success = src.client.LoadMob(choice) //if the load is successful
                    if(success)
                        del(src)//they were loaded, delete this old one
                        return ..()
                    else
                        usr << "" //insert some apology message because they cant be loaded
                        del(src)
                        return ..()
mob
    warrior
        //stuffs here
    wizard
        //stuffs here
    coolguy
        //stuffs here


combining that with the code i have given you, the players will login and see a menu, if they have a previously saved character, it will show up on the list... if they dont, then they can create a new character, when clients are deleted (people log out) their mobs are saved into the save file (in the players folder in your game's directory) If they log back in, their characters will show up on the menu
In response to FIREking

wowzerz. this code = teh ultiam awsumness~!````1`~~

icopied it exactly. i saw thsi exact same code in dbzeta.. and.. apparently theres some stuff ya aint feedin me. so like.. ... find out wtc is wrong?

evenwhen i DID fix teh indention errors.. theres a crapload of more errors..

loading Caits.dme
sav.dm:32:error:F :invalid proc definition
sav.dm:33:error:F.cd:undefined var
sav.dm:34:error:F.dir:undefined var
sav.dm:34:error:= :expected a constant expression
sav.dm:35:error:return characters:instruction not allowed here

Caits.dmb - 5 errors, 0 warnings (double-click on an error to jump to it)






-



loading Caits.dme
sav.dm:32: Inconsistent indentation.
sav.dm:33: Inconsistent indentation.
sav.dm:36: Inconsistent indentation.
sav.dm:37: Inconsistent indentation.
sav.dm:38: Inconsistent indentation.
sav.dm:39: Inconsistent indentation.
sav.dm:40: Inconsistent indentation.
sav.dm:41: Inconsistent indentation.
sav.dm:42: Inconsistent indentation.
sav.dm:43: Inconsistent indentation.
sav.dm:45: Inconsistent indentation.
sav.dm:46: Inconsistent indentation.
sav.dm:47: Inconsistent indentation.
sav.dm:48: Inconsistent indentation.
sav.dm:49: Inconsistent indentation.
sav.dm:50: Inconsistent indentation.
sav.dm:49:warning: empty 'else' clause
sav.dm:51: Inconsistent indentation.
sav.dm:52: Inconsistent indentation.
sav.dm:53: Inconsistent indentation.
sav.dm:54: Inconsistent indentation.
sav.dm:55: Inconsistent indentation.
sav.dm:54:warning: empty 'else' clause
sav.dm:56: Inconsistent indentation.
sav.dm:57: Inconsistent indentation.

Caits.dmb - 28 errors, 2 warnings (double-click on an error to jump to it)
In response to Mashed_The_Hamster
you cant copy code from the forums, unless you fix indentation errors, and know how to do it properly (knowing syntax rules in order to do so)

im done helping you, so if this doesnt help, please allow someone else to answer your question
In response to FIREking
Yea.
i isaid i FIXED the indention errors.. but there are STILL more..

loading Caits.dme
sav.dm:32:error:F :invalid proc definition
sav.dm:33:error:F.cd:undefined var
sav.dm:34:error:F.dir:undefined var
sav.dm:34:error:= :expected a constant expression
sav.dm:35:error:return characters:instruction not allowed here

In response to Mashed_The_Hamster
Yea.
i isaid i FIXED the indention errors.. but there are STILL more..

Just because it doesn't tell you that you have inconsistent indentation errors doesn't mean that the errors you have arn't caused by indentation problems.

The following errors look like they were caused by bad indentation.

loading Caits.dme
sav.dm:32:error:F :invalid proc definition
sav.dm:33:error:F.cd:undefined var
sav.dm:34:error:F.dir:undefined var
sav.dm:34:error:= :expected a constant expression
sav.dm:35:error:return characters:instruction not allowed here