These are the Vars for Mob(player)
mob/Stat()
statpanel("Character") //Creates a new Tab for stats
stat(usr)
stat("Coords - [x],[y],[z]",)
stat("Name:",name) //Every stat() under that will go in the statpanel above
stat("Village:",Village)
stat("Element:",Element)
stat("Rank:",rank)
stat("Yen: [Yen]$")
stat("Level:",Level)
stat("Exp:","[usr.exp] / [usr.max_exp]")//Same with HP and MP.
stat("HP:","[hp]/[maxhp]")
stat("Chakra:","[Chakra]/[maxchakra]")
stat("Tai:",tai)
stat("Nin:",nin)
stat("Gen:",gen)
stat("Defense:",defense)
statpanel("Inventory") //MAkes a new stat panel called inventory
stat(contents) //this is where the contents will go
mob
var
Village //Village used in
Element
Level = 1
defense = 100 //Defense of Character
maxhp = 5000 //Max HP, for when healing (so as not to go over)
hp = 5000 //HP for when getting hurt/dying
maxchakra = 2500 //Max MP for recovering MP
Chakra = 2500 //MP for how much player has
equip = 0
input
SaveSlot
Yen = 100000
//---------------------------------------------------------\\
mob/Login()
world << "<b><font face=tahoma><font size=-1><font color=white>[usr] Logs in"
icon="BaseT.dmi"
icon_state=""
winset(src, "outputwindow.output", "style='icon{width:32;height:32;}';")
usr<<sound('closer.ogg',0)//Play this sound over and over again
usr.loc = locate(9,9,4)//When the mob logs in, take him to this point
mob
Logout()
world << "<font color=white>[usr] has logged out"
src.Save()
..()
sleep(5)
del(usr)
turf
New
icon='player.dmi'
icon_state="New"
density=1
mouse_opacity=2
layer=10
Click()
if(fexists("Playersaves/[usr.ckey].sav"))
alert("There is already a save")
goto REMOVE
REMOVE
switch(input("Delete current save?","Delete?") in list ("Yes","No"))
if("Yes")
usr.Delete_Mob()
if("No")
usr.loc = locate(9,9,4)
turf
Load
icon='player.dmi'
icon_state="Load"
density=1
mouse_opacity=2
layer=10
Click()
var/savefile/F=new("Playersaves/[usr.ckey].sav")
usr.dir = SOUTH
Read(F)
var/newX
var/newY
var/newZ
F["lastx"] >> newX
F["lasty"] >> newY
F["lastz"] >> newZ
usr.loc = locate(newX,newY,newZ)
mob
proc
Save()
var/savefile/F=new("Playersaves/[src.ckey].sav")
src.Write(F)
F["lastx"] << src.x
F["lasty"] << src.y
F["lastz"] << src.z
world << "<b><font face=tahoma><font size=-1><font color=red>[usr] Logs out"
Load()
var/savefile/F=new("Playersaves/[usr.ckey].sav")
usr.Read(F)
var/newX
var/newY
var/newZ
F["lastx"] >> newX
F["lasty"] >> newY
F["lastz"] >> newZ
usr.loc=locate(newX,newY,newZ)
Delete_Mob()
if(fexists("Playersaves/[usr.ckey].sav"))
switch(alert(usr, "Are you sure.", "Character Deletion", "Yes","No"))
if("Yes")
usr<<"<font color=red>Accessing server database...</font>"
var/savefile/F = new("Playersaves/[usr.ckey].sav")
usr<<"<font color=red>Accessing save file...</font>"
sleep(1)
usr.Read(F)
sleep(1)
fdel("Playersave/[usr.ckey].sav")
icon='player.dmi'
icon_state="blank"
usr<<"<font color=red>Save deleted.</font>"
usr.loc = locate(49,9,4)
goto RENAME
RENAME
src.name = input("Your characters name","Set name") as text
if(length(src.name) >= 16)
alert("Sorry, no more characters than 15 characters!")
goto RENAME
if(length(src.name) <= 2)
alert("Sorry, no less than characters than 2 characters!")
goto RENAME
usr.name = name
usr.loc = locate(49,9,4)
if("No")
usr<<"Try load instead."
usr.loc = locate(9,9,4)
else
alert("No savefile found in this slot!")
usr.loc = locate(49,9,4)
Problem description:
Sooo Guys I have this nice little Code "WorkinG" So far.
Its about a New,Load,Delete,Save System
What I need is: A Code which loads the vars such as HP, Chakra whatever ( Yes it is a Naruto game but thank god its no rip)
I have the Locations Working But When I Load the Game there is No saved Icon or the stats are like at the beginning when you create a new character
If you need any piece of Information Just Post it ^^
Im looking forward to your Help and I need this to start working on
That said, one major issue is that you are saving/loading improperly. All logic related to saving and loading go in the Write() and Read() procs, and the actual saving and loading is done by F << mob and F >> mob. Like so:
Additionally, you should not be using goto. At all. Ever. For looping, the appropriate constructs are for() and while(). Of course, looking closer, you have it in other places which make absolutely no goddamned sense. You NEED to remove every single instance of goto in your project.
Furthermore, you should not be using usr in procs. If src isn't correct, then the proc should take an argument which is.