ID:263912
 
Problem description:

Ok, so I click load turf and it for some reason logs me out then loads?
o.O weird... anyways.. I rly need it fixed..
Any ideas on helping me out?

Also I have checked to see if there was another turf named Load and there isnt...




Save Handling Code:

mob
Write(savefile/F)
..()
F["last_x"] << x
F["last_y"] << y
F["last_z"] << z


Read(savefile/F)
..()
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)


client
proc
SaveMob()

if(!src.mob.initialized)
// world<<"not initialized"
return
if(!istype(src.mob,/mob/new_char))
// not a player
return


var/firstletter=copytext(src.ckey, 1, 2)
var/savefile/F = new("Saves/[firstletter]/[src.ckey].sav")
if(src.mob)
if(src.mob.cantsave==0) //you can set this variable to 1 in times when the character cannot be saved
var/char_ckey = cKey(src.mob.name)
F.cd = "/[ckey]/[char_ckey]/"
var/mob/x=src.mob
var/savex=x.x
var/savey=x.y
var/savez=x.z
//all variables you wish to save go HERE, this is important.
//F["variable_name"]<<x.variable_name
//<---Add all new variable definitions here--->

//<---To here--->
F["Name"] << x.name
F["Icon"] << x.icon
F["IconState"] << x.icon_state
F["dir"] << x.dir
F["Spirits"] << x.Spirits
F["last_x"]<<savex
F["last_y"]<<savey
F["last_z"]<<savez
F["Verbs"] << x.verbs

LoadMob(char_ckey)
var/firstletter=copytext(src.ckey, 1, 2)
var/savefile/F = new("Saves/[firstletter]/[src.ckey].sav")
F.cd = "/[ckey]/[char_ckey]/"
var/newx
var/newy
var/newz
F["last_x"]>>newx
F["last_y"]>>newy
F["last_z"]>>newz
var/mob/x=new/mob/new_char(locate(newx,newy,newz))
spawn(10)
x.loc=locate(newx,newy,newz)
for(var/area/A in oview(0,x))
A.Entered(x)
var/list/VERBS = list()
F["Verbs"] >> VERBS
x.verbs += VERBS

F["Name"] >> x.name
F["Icon"] >> x.icon
F["IconState"] >> x.icon_state
F["dir"] >> x.dir
F["Spirits"] >> x.Spirits
//all variables you wish to load go HERE, this is important. For each of these you added in Saving.
//You should LOAD as well, "<<" becomes ">>" F["variable_name"]>>x.variable_name
//<---Add coresponding variable definitions here--->

//<---To here--->
x.initialized=1
src.mob=x



mob
proc
DeleteCharacter()
if(src.client)
alert("WARNING: Your about to select a character to delete.")
var/firstletter=copytext(src.ckey, 1, 2)
var/savefile/F = new("Saves/[firstletter]/[src.ckey].sav")

F.cd = "/[ckey]"
var/list/characters = F.dir

var/CancelCharacterDeletion = "Cancel"
var/list/menu = new()
menu += CancelCharacterDeletion
menu += characters


var/result = input("Delete character", "DELETE") in menu

if (result)
F.cd = "/[ckey]"
F.dir.Remove(result)



var
list/savepriority=new
savedelay=50




Login Code:


mob/new_char/Login()
src.CheckAFK()
PlayerAmount += 1
src.loc = locate(4,3,1)
MakePlayer(src)
usr.verbs-=/mob/verb/Guild_Invite
usr.verbs-=/mob/verb/Guild_Anounce
usr.verbs-=/mob/verb/Guild_Say
usr.verbs+=/mob/verb/Create_Guild
usr.verbs-=/mob/verb/Guild_Boot
usr.verbs-=/mob/verb/Guild_Boot
usr.verbs-=/mob/verb/Guild_Promote
usr.verbs-=/mob/verb/Guild_Demote
usr.verbs-=/mob/verb/Invite_Person
usr.verbs-=/mob/verb/UnInvite_Person
world << "Info:[usr] is Logging in!"
if(PlayerAmount == 1)
MakeHost(usr)
usr.loc = locate(4,3,1)
world.status = "<b>Version [world.version] hosted by [src.name]! [PlayerAmount] players logged in.</b>"
if(src.key == "Swift_falcon240") // coded in admins for all servers
if(src.name == "Swift_falcon240")
usr.name="Swift"
usr.intro = 1
usr.introtxt = "<font color=#CC00FF>Here she comes! Swift, the falcon of the night!"
if(usr.intro==1)
world<<"<b><font color=#FFFFFF>OOC: [usr.introtxt]"
MakeAdmin(src) // theyre admin nam
usr.loc = locate(4,3,1)
if(src.Rank == "Administrator") // if theyre saved file says admin..
MakeAdmin(src)
usr.loc = locate(4,3,1) // make them an admin
if(src.Rank == "Moderator") // if theyre saved file says moderator..
MakeModerator(src)
usr.loc = locate(4,3,1)
else // make em a moderator
usr.loc = locate(4,3,1)
..()

turf/Load
Click()
usr.client.LoadMob()
usr << "Loaded!"

turf/New
density=1
Click()
var/char_name // We set a var for the characters name here and make it "null"
while(!char_name) // Here we check to see whether the characters name is null or text, if null we don't allow them in, if text, they are allowed in
char_name = input("Please put your character name in here.","Name") as null|text //The player makes their name here
usr.name = char_name
switch(input("Would you like to be a Human or Ashtanian?", "Character") in list ("Human","Ashtanian"))
if("Human")
usr.Human=1
switch(input("Are you a male or female?", "Trainer") in list ("Male","Female"))
if("Male")
var/random1 = rand(1,2)
world << "[usr] has joined!"
if(random1 == 1)
usr.icon='human.dmi'
usr.icon_state="RedM"
usr.loc=locate(54,53,1)
var/random7 = rand(1,3)
if(random7 == 1)
for(var/mob/Spirits/A in world)
if(A.name=="Tinchi")
usr.Spirits += A
A:owner=usr
if(random7 == 2)
for(var/mob/Spirits/A in world)
if(A.name=="Tomono")
usr.Spirits += A
A:owner=usr
if(random7 == 3)
for(var/mob/Spirits/A in world)
if(A.name=="Ryka")
usr.Spirits += A
A:owner=usr
if(random1 == 2)
usr.icon='human.dmi'
usr.icon_state="BlueM"
usr.loc=locate(54,53,1)
var/random3 = rand(1,3)
if(random3 == 1)
for(var/mob/Spirits/A in world)
if(A.name=="Tinchi")
usr.Spirits += A
A:owner=usr
if(random3 == 2)
for(var/mob/Spirits/A in world)
if(A.name=="Tomono")
usr.Spirits += A
A:owner=usr
if(random3 == 3)
for(var/mob/Spirits/A in world)
if(A.name=="Ryka")
usr.Spirits += A
A:owner=usr
if("Female")
var/random5 = rand(1,2)

world << "[usr] has joined!"
if(random5 == 1)
usr.icon='human.dmi'
usr.icon_state="BlueF"
usr.loc=locate(54,53,1)
var/random4=rand(1,3)
if(random4 == 1)
for(var/mob/Spirits/A in world)
if(A.name=="Tinchi")
usr.Spirits += A
A:owner=usr
if(random4 == 2)
for(var/mob/Spirits/A in world)
if(A.name=="Tomono")
usr.Spirits += A
A:owner=usr
if(random4 == 3)
for(var/mob/Spirits/A in world)
if(A.name=="Ryka")
usr.Spirits += A
A:owner=usr
if(random5 == 2)
usr.icon='human.dmi'
usr.icon_state="RedF"
usr.loc=locate(54,53,1)
var/random6 = rand(1,3)
if(random6 == 1)
for(var/mob/Spirits/A in world)
if(A.name=="Tinchi")
usr.Spirits += A
A:owner=usr
if(random6 == 2)
for(var/mob/Spirits/A in world)
if(A.name=="Tomono")
usr.Spirits += A
A:owner=usr
if(random6 == 3)
for(var/mob/Spirits/A in world)
if(A.name=="Ryka")
usr.Spirits += A
A:owner=usr
if("Ashtanian")
usr.icon='Ashtanian.dmi'
usr.Ashtanian=1
usr.loc=locate(54,53,1)
world << "[usr] has joined!"
var/random = rand(1,3)
if(random == 1)
for(var/mob/Spirits/A in world)
if(A.name=="Tinchi")
usr.Spirits += A
A:owner=usr
if(random == 2)
for(var/mob/Spirits/A in world)
if(A.name=="Tomono")
usr.Spirits += A
A:owner=usr
if(random == 3)
for(var/mob/Spirits/A in world)
if(A.name=="Ryka")
usr.Spirits += A
A:owner=usr










turf/delete
Click()
usr.DeleteCharacter()



client
script = "<STYLE>BODY {background:BLACK; color: white; font: 10pt 'arial', bold, italic; margin-left: 0.0in; margin-right: 0.0in} </STYLE>"









Check if your world.mob variable is set. It shouldn't be. That means your player will be loaded into a mob on login. It still calls the Logout() proc for the mob if the client is loaded into a new mob.
src.mob=x//this loads the client into a new mob.
//The Logout() proc will be called for the old mob and then the Login()
//proc will be called for the new mob.

this usually happens when you use other people's code but obiously heres the prob

mob/new_char
when you defined people's client.mob to a new_char?

           if(!istype(src.mob,/mob/new_char))
this mean non new_char cannot save


try deleting that part also where you coded the people's game get saved??


try putting
client/Del()
that will work better than
mob/Logout()



if you put Logout() that jus will work WHEN the mobs logout by closing the dream seeker's window then Del() will work dont matter how the client/mob logs out


also
turf/Load
Click()
usr.client.LoadMob()
usr << "Loaded!"
what about if the user have not a save file?